← Back to team overview

team4alfanous team mailing list archive

[Branch ~team4alfanous/alfanous/alfanous-git] Rev 268: Configuration of alfanous/setup.py

 

------------------------------------------------------------
revno: 268
git commit: 501605467be6e2d1ea1f78384ad10e1d6ab6c2f4
committer: Assem Chelli <assem.ch@xxxxxxxxx>
timestamp: Thu 2012-06-14 00:13:12 +0100
message:
  Configuration of alfanous/setup.py
   - include indexes as data files
   - include resources/configs  as data files
   - configure the entry "alfanous-console" to run the function
  alfanous.console:main
modified:
  src/alfanous/console.py
  src/alfanous/setup.py


--
lp:alfanous
https://code.launchpad.net/~team4alfanous/alfanous/alfanous-git

Your team Alfanous team is subscribed to branch lp:alfanous.
To unsubscribe from this branch go to https://code.launchpad.net/~team4alfanous/alfanous/alfanous-git/+edit-subscription
=== modified file 'src/alfanous/console.py'
--- src/alfanous/console.py	2012-06-13 13:19:12 +0000
+++ src/alfanous/console.py	2012-06-13 23:13:12 +0000
@@ -21,17 +21,14 @@
 @contact: assem.ch [at] gmail.com
 @license: AGPL
 
-TODO  show RAW|JSON | BEST-presentation format
-TODO how to configure setup.py to install alfanous-console
-TODO how to run this as a linux service, as a windows service, as a mac service
-
+TODO show RAW|JSON | BEST-presentation format
 '''
 
 import sys, json
 from argparse import ArgumentParser
 from alfanous.outputs import Raw
 
-RAWoutput = Raw( QSE_index = "../../indexes/main/", TSE_index = "../../indexes/extend/", WSE_index = "../../indexes/word/", Recitations_list_file = "../../resources/configs/recitations.js", Translations_list_file = "../../resources/configs/translations.js", Information_file = "../../resources/configs/information.js", Hints_file = "../../resources/configs/hints.js", Stats_file = "../../resources/configs/stats.js" )
+RAWoutput = Raw( QSE_index = "./indexes/main/", TSE_index = "./indexes/extend/", WSE_index = "./indexes/word/", Recitations_list_file = "./resources/configs/recitations.js", Translations_list_file = "./resources/configs/translations.js", Information_file = "./resources/configs/information.js", Hints_file = "./resources/configs/hints.js", Stats_file = "./resources/configs/stats.js" )
 
 INFORMATION = RAWoutput.do( {"action":"show", "query":"information" } )["show"]["information"]
 DOMAINS = RAWoutput.do( {"action":"show", "query":"domains" } )["show"]["domains"]
@@ -79,42 +76,45 @@
 arg_parser.add_argument( "--ident", dest = "ident", type = str  , help = HELPMESSAGES["ident"] )
 arg_parser.add_argument( "--platform", dest = "platform", type = str, choices = DOMAINS["platform"], help = HELPMESSAGES["platform"] )
 arg_parser.add_argument( "--domain", dest = "domain", type = str, help = HELPMESSAGES["domain"] )
+
+
+
+
 #execute command
-args = arg_parser.parse_args()
-
-
-if args.action and args.query:
-    flags = {}
-    if args.action: flags["action"] = args.action
-    if args.query: flags["query"] = args.query
-    if args.ident: flags["ident"] = args.ident
-    if args.platform: flags["platform"] = args.platform
-    if args.domain: flags["domain"] = args.domain
-    if args.sortedby: flags["sortedby"] = args.sortedby
-    if args.page: flags["page"] = args.page
-    if args.perpage: flags["perpage"] = args.perpage
-    if args.offset: flags["offset"] = args.offset
-    if args.range:  flags["range"] = args.range
-    if args.recitation: flags["recitation"] = args.recitation
-    if args.translation: flags["translation"] = args.translation
-    if args.highlight: flags["highlight"] = args.highlight
-    if args.script: flags["script"] = args.script
-    if args.vocalized: flags["vocalized"] = TRUE_FALSE( args.vocalized )
-    if args.prev_aya: flags["prev_aya"] = TRUE_FALSE( args.prev_aya )
-    if args.next_aya: flags["next_aya"] = TRUE_FALSE( args.next_aya )
-    if args.sura_info: flags["sura_info"] = TRUE_FALSE( args.sura_info )
-    if args.word_info: flags["word_info"] = TRUE_FALSE( args.word_info )
-    if args.aya_position_info: flags["aya_position_info"] = TRUE_FALSE( args.aya_position_info )
-    if args.aya_theme_info: flags["aya_theme_info"] = TRUE_FALSE( args.aya_theme_info )
-    if args.aya_stat_info: flags["aya_stat_info"] = TRUE_FALSE( args.aya_stat_info )
-    if args.aya_sajda_info: flags["aya_sajda_info"] = TRUE_FALSE( args.aya_sajda_info )
-    if args.annotation_aya: flags["annotation_aya"] = TRUE_FALSE( args.annotation_aya )
-    if args.annotation_word: flags["annotation_word"] = TRUE_FALSE( args.annotation_word )
-    if args.fuzzy: flags["fuzzy"] = TRUE_FALSE( args.fuzzy )
-
-    print json.dumps( RAWoutput.do( flags ) )
-else:
-    print RAWoutput._information["console_note"]
+def main():
+    args = arg_parser.parse_args()
+    if args.action and args.query:
+        flags = {}
+        if args.action: flags["action"] = args.action
+        if args.query: flags["query"] = args.query
+        if args.ident: flags["ident"] = args.ident
+        if args.platform: flags["platform"] = args.platform
+        if args.domain: flags["domain"] = args.domain
+        if args.sortedby: flags["sortedby"] = args.sortedby
+        if args.page: flags["page"] = args.page
+        if args.perpage: flags["perpage"] = args.perpage
+        if args.offset: flags["offset"] = args.offset
+        if args.range:  flags["range"] = args.range
+        if args.recitation: flags["recitation"] = args.recitation
+        if args.translation: flags["translation"] = args.translation
+        if args.highlight: flags["highlight"] = args.highlight
+        if args.script: flags["script"] = args.script
+        if args.vocalized: flags["vocalized"] = TRUE_FALSE( args.vocalized )
+        if args.prev_aya: flags["prev_aya"] = TRUE_FALSE( args.prev_aya )
+        if args.next_aya: flags["next_aya"] = TRUE_FALSE( args.next_aya )
+        if args.sura_info: flags["sura_info"] = TRUE_FALSE( args.sura_info )
+        if args.word_info: flags["word_info"] = TRUE_FALSE( args.word_info )
+        if args.aya_position_info: flags["aya_position_info"] = TRUE_FALSE( args.aya_position_info )
+        if args.aya_theme_info: flags["aya_theme_info"] = TRUE_FALSE( args.aya_theme_info )
+        if args.aya_stat_info: flags["aya_stat_info"] = TRUE_FALSE( args.aya_stat_info )
+        if args.aya_sajda_info: flags["aya_sajda_info"] = TRUE_FALSE( args.aya_sajda_info )
+        if args.annotation_aya: flags["annotation_aya"] = TRUE_FALSE( args.annotation_aya )
+        if args.annotation_word: flags["annotation_word"] = TRUE_FALSE( args.annotation_word )
+        if args.fuzzy: flags["fuzzy"] = TRUE_FALSE( args.fuzzy )
+
+        print json.dumps( RAWoutput.do( flags ) )
+    else:
+        print RAWoutput._information["console_note"]
 
 
 

=== modified file 'src/alfanous/setup.py'
--- src/alfanous/setup.py	2012-06-01 02:54:15 +0000
+++ src/alfanous/setup.py	2012-06-13 23:13:12 +0000
@@ -5,6 +5,7 @@
 Alfanous Setup Script
 
 """
+import glob
 
 try:
 	from setuptools import setup#,find_packages
@@ -40,7 +41,14 @@
 
 	include_package_data = True,
 
-	#data_files=[ ('indexes/main',glob.glob('indexes/main/*')),('indexes/extend',glob.glob('indexes/extend/*'))],#,('indexes/extend',glob.glob('indexes/extend/*'))
+	data_files = [
+				 ( 'indexes/main', glob.glob( '../../indexes/main/*' ) ),
+				 ( 'indexes/extend', glob.glob( '../../indexes/extend/*' ) ),
+				 ( 'indexes/word', glob.glob( '../../indexes/word/*' ) ),
+				 ( 'resources/configs', glob.glob( '../../resources/configs/*' ) )
+				 ] ,
+
+	entry_points = { 'console_scripts': ['alfanous-console = alfanous.console:main', ]},
 
 	zip_safe = True,