def conf_modified_by_user(version=None): conf = UserConfig('testconfig2', OPTIONS2, version=version) conf_file = file(conf.filename()) lines = conf_file.readlines() conf_file.close() lines = [line.replace('text text','other text') for line in lines] conf_file = file(conf.filename(),'w') conf_file.writelines(lines) conf_file.close() return UserConfig('testconfig2', OPTIONS2, version=version)
def __init__(self): #self.APP_NAME = __application__ self.APP_NAME = 'suzu_ei' #default settings #TODO: group fonts settings self.OPTIONS = [('SentenceFont', #sentences font {'name' : u'Cambria', 'size' : 14, }), ('QuizFont', #quiz answers font {'name' : u'Calibri', 'size' : 12, }), ('MessageFont', #messages font {'name' : u'Cambria', 'size' : 12, }), ('InfoFont', #messages font {'name' : u'Calibri', 'size' : 12, }), ('Intervals', #time constraints {'repetition' : 1, #minutes 'countdown' : 30, #seconds }), ('Active', #active tags and mode {'tags' : [], #tags names (as, jlpt2,3 etc) 'mode' : 'kanji', #kanji, words or both }), ('Launch', #launch options {'autoquiz' : False, #start quiz on launch 'splash' : False, #splash on start }), ('Runtime', #runtime options {'ontop' : True, #always on top 'global' : True, #enable global hotkeys 'log' : False, #enable errors logging 'sound' : False, #enable sound 'fade' : True, #enable fade effect 'background' : False, #draw item color in background 'plastique' : True, #use plastique theme 'preload' : True, #preload jmdict }), ('Session', #session parameters {'size' : 300, #number of items in session 'length' : 600, #maximum repetitions/day }), ('Dict', #dictionary options {'lang' : 'eng', #translation language 'default' : 'jmdict', #default dictionary }), ] #creates or reads from app.ini in Users/username/ self.CONFIG = UserConfig(self.APP_NAME, self.OPTIONS, version=__version__)
def __init__(self): self.defaults = [ ('position', { 'top': False, 'resize': False, 'center': False, 'coordinates': (0, 0), 'size': (0, 0) }), ('states', { 'save_position': False, 'save_size': False, 'save_buttons': False, 'tray': False, 'plastique': False, 'page': False, }), ( 'buttons', { 'toggle': False, 'font': False, 'excluded': False, 'options': False, }, ), ( 'exclude', { 'kana': True, 'duplicates': True, }, ), ] try: self.active_config = UserConfig(_name, self.defaults, version=__version__) except IOError, e: print e
'family' : ['Arial', 'Verdana'], 'size' : 10, 'weight' : 'bold', }), ('Linestyle', {'width' : 2.5, 'style' : 'dash', 'color' : 'blue', }), ] # Creating automatically a .ini file in user home directory # named '.app_name.ini' containing options listed above: # (if the .ini file already exists, its contents will override # those defined above) CONFIG = UserConfig('app_name', OPTIONS) # or, you may (optional) add a version number to your configuration: # (note that this will be the version number of the configuration file, # not of your application! -- at least if you want to keep user old settings) # (when the version number change, the deprecated options are removed -- # here 'deprecated' means: not present in defaults values - here 'OPTIONS') CONFIG = UserConfig('app_name', OPTIONS, version='1.0.2') # How to get options from .ini file: print 'Custom font:', 'yes' if CONFIG.get('Font', 'custom') else 'no' print 'Font family:', CONFIG.get('Font', 'family') # How to get an option default value: # (if .ini file wasn't modified externaly, result will be the same # as the two previous lines)
def save(self, session): '''Save the updated user settings to a new record in the database if the settings have changed. ''' if self._dirty: user_config = UserConfig() # Timestamp user_config.created_date_time = datetime.datetime.now() # Company settings user_config.company_physical_address = \ self.new_company.physical_address user_config.company_gps_coordinates = \ self.new_company.gps_coordinates user_config.company_postal_address = \ self.new_company.postal_address user_config.company_phone_number = self.new_company.phone_number user_config.company_fax_number = self.new_company.fax_number user_config.company_email_address = self.new_company.email_address user_config.company_web_address = self.new_company.web_address user_config.company_signatory_name = \ self.new_company.signatory_name user_config.company_signature_filename = \ self.new_company.signature_filename user_config.company_logo_filename = self.new_company.logo_filename # Purchase order settings user_config.default_payment_terms = \ self.new_purchaseorder.default_payment_terms user_config.default_order_status = \ self.new_purchaseorder.default_order_status # Locale settings. Assumes that the validate method has been called. user_config.tax_rate = percentage_decimal_to_int( self.new_locale.tax_rate) # Commit session.add(user_config) session.commit() self._dirty = False
class Options: def __init__(self): #self.APP_NAME = __application__ self.APP_NAME = 'suzu_ei' #default settings #TODO: group fonts settings self.OPTIONS = [('SentenceFont', #sentences font {'name' : u'Cambria', 'size' : 14, }), ('QuizFont', #quiz answers font {'name' : u'Calibri', 'size' : 12, }), ('MessageFont', #messages font {'name' : u'Cambria', 'size' : 12, }), ('InfoFont', #messages font {'name' : u'Calibri', 'size' : 12, }), ('Intervals', #time constraints {'repetition' : 1, #minutes 'countdown' : 30, #seconds }), ('Active', #active tags and mode {'tags' : [], #tags names (as, jlpt2,3 etc) 'mode' : 'kanji', #kanji, words or both }), ('Launch', #launch options {'autoquiz' : False, #start quiz on launch 'splash' : False, #splash on start }), ('Runtime', #runtime options {'ontop' : True, #always on top 'global' : True, #enable global hotkeys 'log' : False, #enable errors logging 'sound' : False, #enable sound 'fade' : True, #enable fade effect 'background' : False, #draw item color in background 'plastique' : True, #use plastique theme 'preload' : True, #preload jmdict }), ('Session', #session parameters {'size' : 300, #number of items in session 'length' : 600, #maximum repetitions/day }), ('Dict', #dictionary options {'lang' : 'eng', #translation language 'default' : 'jmdict', #default dictionary }), ] #creates or reads from app.ini in Users/username/ self.CONFIG = UserConfig(self.APP_NAME, self.OPTIONS, version=__version__) ### fonts ### def getSentenceFont(self): return self.CONFIG.get('SentenceFont', 'name') def getQuizFont(self): return self.CONFIG.get('QuizFont', 'name') def getMessageFont(self): return self.CONFIG.get('MessageFont', 'name') def getInfoFont(self): return self.CONFIG.get('InfoFont', 'name') def getSentenceFontSize(self): return self.CONFIG.get('SentenceFont', 'size') def getQuizFontSize(self): return self.CONFIG.get('QuizFont', 'size') def getMessageFontSize(self): return self.CONFIG.get('MessageFont', 'size') ### intervals ### def getRepetitionInterval(self): return self.CONFIG.get('Intervals', 'repetition') def getCountdownInterval(self): return self.CONFIG.get('Intervals', 'countdown') def setRepetitionInterval(self, interval): self.CONFIG.set('Intervals', 'repetition', interval) def setCountdownInterval(self, interval): self.CONFIG.set('Intervals', 'countdown', interval) ### session ### def getSessionSize(self): return self.CONFIG.get('Session', 'size') def getSessionLength(self): return self.CONFIG.get('Session', 'length') def setSessionSize(self, number): self.CONFIG.set('Session', 'size', number) def setSessionLength(self, number): self.CONFIG.set('Session', 'length', number) ### launch ### def isQuizStartingAtLaunch(self): return self.CONFIG.get('Launch', 'autoquiz') def setQuizStartingAtLaunch(self, flag): self.CONFIG.set('Launch', 'autoquiz', flag) def isSplashEnabled(self): return self.CONFIG.get('Launch', 'splash') def setSplashEnabled(self, flag): return self.CONFIG.get('Launch', 'splash', flag) ### quiz ### def getQuizMode(self): return self.CONFIG.get('Active', 'mode') ### runtime ### def isAlwaysOnTop(self): return self.CONFIG.get('Runtime', 'ontop') def isSoundOn(self): return self.CONFIG.get('Runtime', 'sound') def isGlobalHotkeyOn(self): return self.CONFIG.get('Runtime', 'global') def isLoggingOn(self): return self.CONFIG.get('Runtime', 'log') def isBackgroundOn(self): return self.CONFIG.get('Runtime', 'background') def isFadeEffectOn(self): return self.CONFIG.get('Runtime', 'fade') def isPlastique(self): return self.CONFIG.get('Runtime', 'plastique') def isPreloading(self): return self.CONFIG.get('Runtime', 'preload') def setAlwaysOnTop(self, flag): self.CONFIG.set('Runtime', 'ontop', flag) def setSoundOn(self, flag): self.CONFIG.set('Runtime', 'sound', flag) def setGlobalHotkeyOn(self, flag): self.CONFIG.set('Runtime', 'global', flag) def setLoggingOn(self, flag): self.CONFIG.set('Runtime', 'log', flag) def setFadeEffectOn(self, flag): self.CONFIG.set('Runtime', 'fade', flag) def setBackgroundOn(self, flag): self.CONFIG.set('Runtime', 'background', flag) def setPlastique(self, flag): self.CONFIG.set('Runtime', 'plastique', flag) def setPreloading(self, flag): self.CONFIG.set('Runtime', 'preload', flag) ### dictionary ### def getLookupLang(self): return self.CONFIG.get('Dict', 'lang') def setLookupLang(self, lang): self.CONFIG.set('Dict', 'lang', lang) def getLookupDict(self): return self.CONFIG.get('Dict', 'default') def setLookupDict(self, dict): self.CONFIG.set('Dict', 'default', dict)
def setUp(self): self.conf = UserConfig('testconfig1', OPTIONS1)
def test_same_config_version(self): conf_modified_by_user(version='1.0.1') conf = UserConfig('testconfig2', OPTIONS2, version='1.0.1') o_str = conf.get('category2', 'str') self.assertEquals(o_str, 'other text')
def test_load_false(self): conf_modified_by_user() conf = UserConfig('testconfig2', OPTIONS2, load=False) o_str = conf.get('category2', 'str') self.assertEquals(o_str, 'text text')
def test_cleanup(self): conf = UserConfig('testconfig1', OPTIONS1) conf.cleanup() self.assertTrue( not os.path.isfile(conf.filename()) )
def test_exist2(self): conf = UserConfig('testconfig2', OPTIONS2) self.assertTrue( os.path.isfile(conf.filename()) )
def setUp(self): self.conf = UserConfig('testconfig2', OPTIONS2, load=False)
class TestOptions2(unittest.TestCase): def setUp(self): self.conf = UserConfig('testconfig2', OPTIONS2, load=False) def tearDown(self): self.conf.cleanup() def test_get_float(self): o_float = self.conf.get('category1', 'float') self.assertEquals(o_float, 12.3) def test_set_float(self): self.conf.set('category1', 'float', 14.5) o_float = self.conf.get('category1', 'float') self.assertEquals(o_float, 14.5) def test_get_int(self): o_int = self.conf.get('category2', 'int') self.assertEquals(o_int, 50) def test_get_bool(self): o_bool = self.conf.get('category1', 'bool') self.assertEquals(o_bool, True) def test_get_str(self): o_str = self.conf.get('category2', 'str') self.assertEquals(o_str, 'text text') def test_get_unicode(self): o_unicode = self.conf.get('category3', 'unicode') self.assertEquals(o_unicode, u'ééǿùùàà') def test_get_default(self): o_default = self.conf.get('category3', 'unknown', default=23) self.assertEquals(o_default, 23)
'exclude_regexp': True, 'search_text_regexp': True, 'search_text': [''], 'search_text_samples': [r'# ?TODO|# ?FIXME|# ?XXX'], }), ('pylint', { 'enable': True, 'max_entries': 50, }), ] DEV = not __file__.startswith(sys.prefix) DEV = False CONF = UserConfig('spyder', defaults=DEFAULTS, load=(not DEV), version='1.0.6', subfolder='.spyder') # Removing old .spyder.ini location: old_location = osp.join(get_home_dir(), '.spyder.ini') if osp.isfile(old_location): os.remove(old_location) def get_conf_path(filename=None): """Return absolute path for configuration file with specified filename""" conf_dir = osp.join(get_home_dir(), '.spyder') if not osp.isdir(conf_dir): os.mkdir(conf_dir) if filename is None: return conf_dir
@staticmethod def _add_tag_to_blurb(tag, blurb_id): b = Blurb.select().where(Blurb.id == blurb_id) Tag.create(text=tag.lower().strip(), blurb=b) @staticmethod def reset_all_tables(): Tag.drop_table() Blurb.drop_table() Blurb.create_table(fail_silently=True) Tag.create_table(fail_silently=True) if __name__ == "__main__": a = ApplicationBuilder(UserConfig()) desc = '''Co-Op – Applications and Testing Insurance Corporation of British Columbia 73 reviews - North Vancouver, BC A career at ICBC is an opportunity to be part of a talented, diverse and inclusive team that is driven to serve its customers and community. Make the most of your skills and take the opportunity to grow and develop your career. You can expect a competitive salary, comprehensive benefits and a challenging work environment. Drive your career with us. ICBC is an equal opportunity employer, and invites applications from all qualified candidates. Co-Op – Applications and Testing Job Title: (O) Coop Student Wt 2 Location: North Vancouver Hours of Work: 7.5 hr Day Shift (M-F) Reference Number: 109906
'-"accounts payable" -"plumber"' params = { 'q': q1, 'limit': '25', # 'jt':'internship', 'fromage': '10', 'language': 'en', 'co': 'ca', 'userip': "1.2.3.4", 'useragent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" } print(unformatted_display_query.format(q1)) bot = IndeedRobot(UserConfig()) bot.search_with_api(params=params) bot.login() bot.apply_jobs() bot.shut_down() elif args.option == JobBot.AngelBot.value: query_parameters = { "types": "internship", "roles": ["Software Engineer"], "last_active": "30", "excluded_keywords": ["unpaid"] } print(unformatted_display_query.format(query_parameters)) bot = AngelBot(UserConfig())
class TestOptions1(unittest.TestCase): def setUp(self): self.conf = UserConfig('testconfig1', OPTIONS1) def tearDown(self): self.conf.cleanup() def test_get_list(self): o_list = self.conf.get(None, 'category1/list') self.assertEquals(o_list, [5, "kk"]) def test_set_list(self): self.conf.set(None, 'category1/list', [14.5, "jj"]) o_list = self.conf.get(None, 'category1/list') self.assertEquals(o_list, [14.5, "jj"]) def test_get_tuple(self): o_tuple = self.conf.get(None, 'category1/tuple') self.assertEquals(o_tuple, (None, "foo")) def test_set_tuple(self): self.conf.set(None, 'category1/tuple', (False, 1238, 3.5)) o_tuple = self.conf.get(None, 'category1/tuple') self.assertEquals(o_tuple, (False, 1238, 3.5)) def test_get_float(self): o_float = self.conf.get(None, 'category1/float') self.assertEquals(o_float, 12.3) def test_set_float(self): self.conf.set(None, 'category1/float', 14.5) o_float = self.conf.get(None, 'category1/float') self.assertEquals(o_float, 14.5) def test_get_int(self): o_int = self.conf.get(None, 'category2/int') self.assertEquals(o_int, 50) def test_set_int(self): self.conf.set(None, 'category2/int', 10.0) o_int = self.conf.get(None, 'category2/int') self.assertEquals(o_int, 10) def test_get_bool(self): o_bool = self.conf.get(None, 'category1/bool') self.assertEquals(o_bool, True) def test_set_bool(self): self.conf.set(None, 'category1/bool', False) o_bool = self.conf.get(None, 'category1/bool') self.assertEquals(o_bool, False) def test_get_str(self): o_str = self.conf.get(None, 'category2/str') self.assertEquals(o_str, 'text text') def test_set_str(self): self.conf.set(None, 'category2/str', 'foobar') o_str = self.conf.get(None, 'category2/str') self.assertEquals(o_str, 'foobar') def test_get_unicode(self): o_unicode = self.conf.get(None, 'category3/unicode') self.assertEquals(o_unicode, u'ééǿùùàà') def test_set_unicode(self): self.conf.set(None, 'category3/unicode', u'ééǿùùàà') o_unicode = self.conf.get(None, 'category3/unicode') self.assertEquals(o_unicode, u'ééǿùùàà')