@ -11,6 +11,7 @@ from . import commands
from . import plugins
from . import plugins
from . __init__ import __version__
from . __init__ import __version__
cmds = collections . OrderedDict ( [
cmds = collections . OrderedDict ( [
( ' init ' , commands . init_cmd ) ,
( ' init ' , commands . init_cmd ) ,
( ' add ' , commands . add_cmd ) ,
( ' add ' , commands . add_cmd ) ,
@ -26,18 +27,20 @@ cmds = collections.OrderedDict([
( ' update ' , commands . update_cmd ) ,
( ' update ' , commands . update_cmd ) ,
] )
] )
def _update_check ( config , ui ) :
def _update_check ( config , ui ) :
if config . version_warning :
if config . version_warning :
code_version = int ( __version__ )
code_version = int ( __version__ )
repo_version = int ( config . version )
repo_version = int ( config . version )
if repo_version > code_version :
if repo_version > code_version :
ui . print_ ( ' warning: your repository was generated with an newer version '
ui . warning (
' of papers (v {} ) than the one you are using (v {} ). \n ' . format (
' your repository was generated with an newer version '
repo_version , code_version ) +
' of papers (v {} ) than the one you are using (v {} ). '
' you should not use papers until you install the '
' \n ' . format ( repo_version , code_version ) +
' newest version. (use version_warning in you papersrc '
' You should not use papers until you install the '
' to bypass this error) ' )
' newest version. (use version_warning in you papersrc '
' to bypass this error) ' )
sys . exit ( )
sys . exit ( )
elif repo_version < code_version :
elif repo_version < code_version :
ui . print_ (
ui . print_ (
@ -47,7 +50,7 @@ def _update_check(config, ui):
sys . exit ( )
sys . exit ( )
def execute ( raw_args = sys . argv ) :
def execute ( raw_args = sys . argv ) :
# loading config
# loading config
config = configs . Config ( )
config = configs . Config ( )
config . load ( )
config . load ( )
@ -58,17 +61,16 @@ def execute(raw_args = sys.argv):
_update_check ( config , ui )
_update_check ( config , ui )
# Extend with plugin commands
plugins . load_plugins ( ui , config . plugins . split ( ) )
for p in plugins . get_plugins ( ) . values ( ) :
if getattr ( p , ' parser ' ) and getattr ( p , ' command ' ) :
cmds . update ( collections . OrderedDict ( [ ( p . name , p ) ] ) )
parser = argparse . ArgumentParser ( description = " research papers repository " )
parser = argparse . ArgumentParser ( description = " research papers repository " )
subparsers = parser . add_subparsers ( title = " valid commands " , dest = " command " )
subparsers = parser . add_subparsers ( title = " valid commands " , dest = " command " )
for cmd_mod in cmds . values ( ) :
for cmd_mod in cmds . values ( ) :
subparser = cmd_mod . parser ( subparsers ) # why do we return the subparser ?
cmd_mod . parser ( subparsers )
# Extend with plugin commands
plugins . load_plugins ( ui , config . plugins . split ( ) )
for p in plugins . get_plugins ( ) . values ( ) :
cmds . update ( p . get_commands ( subparsers ) )
args = parser . parse_args ( raw_args [ 1 : ] )
args = parser . parse_args ( raw_args [ 1 : ] )
cmd = args . command
cmd = args . command