<s> import os <EOL> import sys <EOL> import git_orm <EOL> from tiget . plugins . settings import * <EOL> class RepositorySetting ( Setting ) : <EOL> def clean ( self , value ) : <EOL> try : <EOL> git_orm . set_repository ( value ) <EOL> except git_orm . GitError as e : <EOL> raise ValueError ( e ) <EOL> return git_orm . get_repository ( ) <EOL> def format ( self , repo ) : <EOL> repo = git_orm . get_repository ( ) <EOL> path = repo . path if repo else None <EOL> return super ( ) . format ( path ) <EOL> class BranchSetting ( Setting ) : <EOL> def clean ( self , value ) : <EOL> git_orm . set_branch ( value ) <EOL> return git_orm . get_branch ( ) <EOL> def format ( self , repo ) : <EOL> return super ( ) . format ( git_orm . get_branch ( ) ) <EOL> class RemoteSetting ( Setting ) : <EOL> def clean ( self , value ) : <EOL> git_orm . set_remote ( value ) <EOL> return git_orm . get_remote ( ) <EOL> def format ( self , repo ) : <EOL> return super ( ) . format ( git_orm . get_remote ( ) ) <EOL> def load ( plugin ) : <EOL> from tiget . core import cmds <EOL> plugin . add_cmds ( cmds ) <EOL> plugin . add_settings ( <EOL> branch = BranchSetting ( ) , <EOL> remote = RemoteSetting ( ) , <EOL> debug = BoolSetting ( default = False ) , <EOL> color = BoolSetting ( default = sys . stdout . isatty ( ) ) , <EOL> editor = StrSetting ( default = os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) ) , <EOL> history_file = StrSetting ( default = '<STR_LIT>' ) , <EOL> history_limit = IntSetting ( default = <NUM_LIT:1000> ) , <EOL> pager = StrSetting ( default = os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) ) , <EOL> pdb_module = StrSetting ( default = '<STR_LIT>' ) , <EOL> repository = RepositorySetting ( ) , <EOL> ) <EOL> plugin . settings . branch = '<STR_LIT>' <EOL> plugin . settings . remote = '<STR_LIT>' <EOL> try : <EOL> plugin . settings . repository = '<STR_LIT:.>' <EOL> except ValueError : <EOL> pass </s>
