Python config.version() Examples
The following are 20
code examples of config.version().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
config
, or try the search function
.
Example #1
Source File: __init__.py From wxGlade with MIT License | 6 votes |
def quote_str(self, s): """Returns a quoted / escaped version of 's', suitable to insert in a source file as a string object. Takes care also of gettext support. Escaped are: quotations marks, backslash, characters with special meaning Please use quote_path() to quote / escape filenames or paths. Please check the test case tests.test_codegen.TestCodeGen.test_quote_str() for additional infos. The language specific implementations are in _quote_str().""" if not s: return self.tmpl_empty_string # no longer with direct generation: ## this is called from the Codewriter which is fed with XML ## here newlines are escaped already as '\n' and '\n' two-character sequences as '\\n' ## so we start by unescaping these #s = np.TextProperty._unescape(s) # then escape as required s = s.replace("\\", "\\\\").replace("\n", "\\n").replace("\t", "\\t").replace('"', '\\"') return self._quote_str(s)
Example #2
Source File: testsupport_new.py From wxGlade with MIT License | 6 votes |
def setUpClass(cls): "Initialise parts of wxGlade before individual tests starts" # set icon path back to the default default #config.icons_path = 'icons' # initialise wxGlade preferences and set some useful values common.init_preferences() config.preferences.autosave = False config.preferences.write_timestamp = False config.preferences.show_progress = False #config.version = '"faked test version"' # make e.g. the preview raise Exceptions config.testing = True # Determinate case and output directory cls.caseDirectory = os.path.join( os.path.dirname(__file__), cls.caseDirectory ) cls.outDirectory = os.path.join( os.path.dirname(__file__), cls.outDirectory ) if not os.path.exists(cls.outDirectory): os.mkdir(cls.outDirectory) # disable bug dialogs sys._called_from_test = True
Example #3
Source File: application.py From wxGlade with MIT License | 5 votes |
def _set_language(self): "Set code generator language and adapt corresponding settings like file dialog wild cards (value: str or int)" language = self.language # update wildcards and default extension in the dialog self._update_output_path(language) # check that the new language supports all the widgets in the tree self.check_codegen() # disable lisp for wx > 2.8 if language == 'lisp': for_version = self.for_version if for_version == '3.0': misc.warning_message( _('Generating Lisp code for wxWidgets version %s is not supported.\n' 'Set version to "2.8" instead.') % self.for_version ) self.properties["for_version"].set('2.8') self.properties["for_version"].set_blocked(True) else: self.properties["for_version"].set_blocked(False) # don't change the extension in multiple files mode if self.multiple_files == 1: return # update file extensions current_name = self.output_path if not current_name: return base, ext = os.path.splitext(current_name) # is already a valid extension? ext has a leading . but default_extensions hasn't if ext and ext[1:] in common.code_writers[language].default_extensions: return new_name = "%s.%s" % (base, common.code_writers[language].default_extensions[0]) self.properties["output_path"].set(new_name) blocked = self.language!="C++" self.properties["source_extension"].set_blocked(blocked) self.properties["header_extension"].set_blocked(blocked) # properties: saved and filename
Example #4
Source File: ip_crawl_tool.py From SSTAP_ip_crawl_tool with GNU General Public License v3.0 | 5 votes |
def update_data(self,exe_list,name_en,name_zh): host = config.server port = config.port# 设置端口号 try: s.connect((host,port)) #print(s.recv(1024)) #print(self.de_msg(self.rec())) print('服务器连接成功') except: print('服务器连接失败') pass temp = '#{},{},0,0,1,0,1,0,By-ip_crawl_tool\n'.format(name_en,name_zh) while True: time.sleep(1) f = open("{}.rules".format(str(exe_list)), 'r',encoding='utf-8') f_temp = f.read() if f_temp != temp:#判断和上次传送结果是否重复,降低服务器压力 temp = f_temp msg = {'rules':f_temp,'process':exe_list,'version':config.version}#加入进程名和版本号 msg = self.en_msg(str(msg)) s.send(msg) f.close() continue s.close()
Example #5
Source File: application.py From wxGlade with MIT License | 5 votes |
def set_for_version(self, value): self.for_version = self.for_version_prop.get_string_value() if self.for_version.startswith('3.'): ## disable lisp for wx > 2.8 if self.codewriters_prop.get_string_value() == 'lisp': misc.warning_message( _('Generating Lisp code for wxWidgets version %s is not supported.\n' 'Set version to "2.8" instead.') % self.for_version ) self.for_version_prop.set_str_value('2.8') self.set_for_version('2.8') return self.codewriters_prop.enable_item('lisp', False) else: # enable lisp again self.codewriters_prop.enable_item('lisp', True)
Example #6
Source File: application.py From wxGlade with MIT License | 5 votes |
def write(self, output, tabs=0): """Writes the xml equivalent of this tree to the given output file. This function writes unicode to the outfile.""" # XXX move this to application.Application timestring = time.asctime() if not config.testing else 'XXX XXX NN NN:NN:NN NNNN' output.append( u'<?xml version="1.0"?>\n' u'<!-- generated by wxGlade %s on %s -->\n\n' % (config.version, timestring) ) attrs = ["name","class","language","top_window","encoding","use_gettext", "overwrite", "mark_blocks", "for_version","is_template","indent_amount"] props = [self.properties[attr] for attr in attrs] attrs = dict( (attr,prop.get_string_value()) for attr,prop in zip(attrs,props) if not prop.deactivated ) top_window_p = self.properties["top_window"] if top_window_p.deactivated and top_window_p.value: attrs["top_window"] = top_window_p.value attrs["option"] = self.properties["multiple_files"].get_string_value() attrs["indent_symbol"] = self.properties["indent_mode"].get_string_value() attrs["path"] = self.properties["output_path"].get_string_value() attrs['use_new_namespace'] = 1 # add a . to the file extensions attrs["source_extension"] = '.' + self.properties["source_extension"].get_string_value() attrs["header_extension"] = '.' + self.properties["header_extension"].get_string_value() inner_xml = [] if self.is_template and getattr(self, 'template_data', None): self.template_data.write(inner_xml, tabs+1) for c in self.children: c.write(inner_xml, tabs+1) output.extend( common.format_xml_tag( u'application', inner_xml, is_xml=True, **attrs ) )
Example #7
Source File: __init__.py From wxGlade with MIT License | 5 votes |
def create_generated_by(self): "Create I{generated by wxGlade} string without leading comment characters and without tailing new lines" generated_from = '' if config.preferences.write_generated_from and common.app_tree and common.root.filename: generated_from = ' from "%s"' % common.root.filename if config.preferences.write_timestamp: msg = 'generated by wxGlade %s on %s%s' % ( config.version, time.asctime(), generated_from ) else: msg = 'generated by wxGlade%s' % generated_from return msg
Example #8
Source File: __init__.py From wxGlade with MIT License | 5 votes |
def _get_object_builder(self, parent_klass, obj): "Perform some checks and return the code builder" # Check for widget builder object try: builder = self.obj_builders[obj.WX_CLASS] except KeyError: # no code generator found: write a comment about it name = getattr(obj, "name", "None") name = self._format_name(name) msg = _('Code for instance "%s" of "%s" not generated: no suitable writer found') % (name, obj.WX_CLASS ) self._source_warning(parent_klass, msg, obj) self.warning(msg) return None # check for supported versions if hasattr(builder, 'is_widget_supported'): is_supported = builder.is_widget_supported(*self.for_version) else: is_supported = True if not is_supported: supported_versions = [misc.format_supported_by(version) for version in builder.config['supported_by']] msg = _('Code for instance "%(name)s" of "%(klass)s" was\n' 'not created, because the widget is not available for wx version %(requested_version)s.\n' 'It is available for wx versions %(supported_versions)s only.') % { 'name': self._format_name(obj.name), 'klass': obj.klass, 'requested_version': str(misc.format_for_version(self.for_version)), 'supported_versions': ', '.join(supported_versions) } self._source_warning(parent_klass, msg, obj) self.warning(msg) return None return builder
Example #9
Source File: about.py From wxGlade with MIT License | 5 votes |
def __init__(self, parent=None): wx.Dialog.__init__(self, parent, -1, _('About wxGlade')) html = wx.html.HtmlWindow(self, -1, size=(480, 250)) html.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked) # it's recommended at least for GTK2 based wxPython if "gtk2" in wx.PlatformInfo: html.SetStandardFonts() bgcolor = misc.color_to_string(self.GetBackgroundColour()) icon_path = os.path.join(config.icons_path, 'wxglade_small.png') html.SetPage( self.text % (bgcolor, icon_path, config.version, config.py_version, config.wx_version) ) ir = html.GetInternalRepresentation() ir.SetIndent(0, wx.html.HTML_INDENT_ALL) html.SetSize((ir.GetWidth(), ir.GetHeight())) szr = wx.BoxSizer(wx.VERTICAL) szr.Add(html, 0, wx.TOP|wx.ALIGN_CENTER, 10) szr.Add(wx.StaticLine(self, -1), 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 20) szr2 = wx.BoxSizer(wx.HORIZONTAL) btn = wx.Button(self, wx.ID_OK, _("OK")) btn.SetDefault() szr2.Add(btn) if wx.Platform == '__WXGTK__': extra_border = 5 # border around a default button else: extra_border = 0 szr.Add(szr2, 0, wx.ALL|wx.ALIGN_RIGHT, 20 + extra_border) self.SetAutoLayout(True) self.SetSizer(szr) szr.Fit(self) self.Layout() if parent: self.CenterOnParent() else: self.CenterOnScreen()
Example #10
Source File: tree_ctrl.py From wxGlade with MIT License | 5 votes |
def create_widget(self): self.widget = wx.TreeCtrl(self.parent_window.widget, self.id, style=self.style) # wx.TR_HAS_BUTTONS|wx.BORDER_SUNKEN) # add a couple of items just for a better appearance root = self.widget.AddRoot(_(' Tree Control:')) self._item_with_name = self.widget.AppendItem(root, ' ' + self.name) self.widget.AppendItem(self._item_with_name, _(' on wxGlade version %s') % config.version ) self.widget.Expand(root) self.widget.Expand(self._item_with_name)
Example #11
Source File: wxglade.py From wxGlade with MIT License | 5 votes |
def init_stage2(use_gui): """Initialise the remaining (non-path) parts of wxGlade (second stage) use_gui: Starting wxGlade GUI""" config.use_gui = use_gui if use_gui: # import proper wx-module using wxversion, which is only available in Classic if compat.IS_CLASSIC: if not hasattr(sys, "frozen") and 'wx' not in sys.modules: try: import wxversion wxversion.ensureMinimal('2.8') except ImportError: msg = _('Please install missing Python module "wxversion".') logging.error(msg) sys.exit(msg) try: import wx except ImportError: msg = _('Please install missing Python module "wxPython".') logging.error(msg) sys.exit(msg) # store current version and platform ('not_set' is default) config.platform = wx.Platform config.wx_version = wx.__version__ if sys.platform=="win32": # register ".wxg" extension try: import msw msw.register_extensions(["wxg"], "wxGlade") except ImportError: pass # codewrites, widgets and sizers are loaded in class main.wxGladeFrame else: # use_gui has to be set before importing config common.init_preferences() common.init_codegen()
Example #12
Source File: wxglade.py From wxGlade with MIT License | 5 votes |
def init_stage1(options): """Initialise paths for wxGlade (first stage) Initialisation is split because the test suite doesn't work with proper initialised paths.""" config.version = config.get_version() common.init_paths(options) # initialise own logging extensions log.init(filename=config.log_file, encoding='utf-8', level='INFO') atexit.register(log.deinit) # print versions logging.info( _('Starting wxGlade version "%s" on Python %s'), config.version, config.py_version ) # print used paths logging.info(_('Base directory: %s'), config.wxglade_path) logging.info(_('Documentation directory: %s'), config.docs_path) logging.info(_('Icons directory: %s'), config.icons_path) logging.info(_('Build-in widgets directory: %s'), config.widgets_path) logging.info(_('Template directory: %s'), config.templates_path) logging.info(_('Credits file: %s'), config.credits_file) logging.info(_('License file: %s'), config.license_file) logging.info(_('Manual file: %s'), config.manual_file) logging.info(_('Tutorial file: %s'), config.tutorial_file) logging.info(_('Home directory: %s'), config.home_path) logging.info(_('Application data directory: %s'), config.appdata_path) logging.info(_('Configuration file: %s'), config.rc_file) logging.info(_('History file: %s'), config.history_file) logging.info(_('Log file: %s'), config.log_file) # adapt application search path sys.path.insert(0, config.wxglade_path) sys.path.insert(1, config.widgets_path)
Example #13
Source File: telegram_main.py From convai-bot-1337 with GNU General Public License v3.0 | 5 votes |
def _help_cmd(self, bot, update): self._log_user('_help_cmd', update) self._add_fsm_and_user(update) message = ("/start - starts the chat\n" "/text - shows current text to discuss\n" "/help - shows this message\n" "/reset - reset the bot\n" "/stop - stop the bot\n" "/evaluation_start - start the evaluation mode \n" "/evaluation_end - end the evaluation mode and save eval data \n" "\n" "Version: {}".format(version)) update.message.reply_text(message)
Example #14
Source File: upmp_service.py From unionpay with MIT License | 5 votes |
def query(order_id, order_time): ''' 查询接口 参数 order_id - 交易ID order_time - 交易时间,datetime类型 返回 成功 - 返回结果字典 失败 - 返回None ''' req = { 'version': config.version, 'charset': config.charset, 'transType': '01', 'merId': config.mer_id, 'backEndUrl': config.mer_backend_url, 'orderTime': datetime.datetime.strftime(datetime.datetime.now(), "%Y%m%d%H%M%S"), 'orderNumber': str(order_id), } r = requests.post(config.query_url, build_req(req)) if r.status_code == 200: return parse_response(r.text) else: return None
Example #15
Source File: upmp_service.py From unionpay with MIT License | 5 votes |
def trade(order_id, amount, order_time): ''' 交易接口 参数 order_id - 交易ID amount - 交易实际金额 order_time - 交易时间,datetime类型 返回 成功 - 返回结果字典 失败 - 返回None ''' order_timeout = datetime.datetime.now() + datetime.timedelta(minutes=5) req = { 'version': config.version, 'charset': config.charset, 'transType': '01', 'merId': config.mer_id, 'backEndUrl': config.mer_backend_url, 'orderTime': datetime.datetime.strftime(order_time, "%Y%m%d%H%M%S"), 'orderTimeout': datetime.datetime.strftime(order_timeout, "%Y%m%d%H%M%S"), 'orderNumber': str(order_id), # 要求金额字段为 包含角和分、没有小数点的字符串 'orderAmount': str(amount * 100), } r = requests.post(config.trade_url, build_req(req)) if r.status_code == 200: return parse_response(r.text) else: return None
Example #16
Source File: ip_crawl_tool.py From SSTAP_ip_crawl_tool with GNU General Public License v3.0 | 5 votes |
def main(): #test() global udp_point print('ip_crawl_tool'+config.version) print('3.0版增加上传规则至服务器进行共享,如不想进行规则上传,请使用2.0版') print('快速版规则请访问 '+config.web_url) a = input('请输入游戏进程名(可启动游戏后在任务管理器 进程 中查询)\n如果有多个进程请使用英文逗号分隔开:') udp_point = input('是否抓取udp协议ip,默认不抓取。\n抓取udp协议ip需使用管理员权限运行,且需要开启windows防火墙,请确保使用管理员权限运行本程序和开启了防火请。\n如需抓取udp协议请输入1:') exe_list = a.split(',') print('将检测以下程序') for exe in exe_list: print(exe) print('请核对名称是否正确,如不正确请重新启动输入') run(exe_list)
Example #17
Source File: __init__.py From wxGlade with MIT License | 4 votes |
def new_project(self, app, out_path=None, preview=False): "Initialise generic and language independent code generator settings; see init_lang(), init_files()" # set (most of) instance variables back to default values self._init_vars() # application name self.app_name = app.name if self.app_name: self.app_filename = '%s.%s' % ( self.app_name, self.default_extensions[0] ) self._textdomain = self.app_name # file encoding self.app_encoding = app.encoding.upper() or config.default_encoding # wx doesn't like latin-1 if self.app_encoding == 'latin-1': self.app_encoding = 'ISO-8859-1' # Indentation symbol and level based on the project options self.indent_symbol = app.properties["indent_mode"].get_string_value() if self.indent_symbol == 'tab': self.indent_symbol = '\t' elif self.indent_symbol == 'space': self.indent_symbol = ' ' else: self.indent_symbol = config.default_indent_symbol self.indent_amount = app.indent_amount if preview: self.multiple_files = False self._overwrite = True self._mark_blocks = False self._use_gettext = False else: self.multiple_files = app.multiple_files self._overwrite = app.overwrite self._mark_blocks = True if self._overwrite else app.mark_blocks self._use_gettext = app.use_gettext if not preview: self.for_version = tuple([int(t) for t in app.for_version.split('.')[:2]]) else: self.for_version = compat.version self.is_template = app.is_template if self.multiple_files: self.out_dir = out_path or config.default_output_path else: self.out_dir = out_path or config.default_output_file self.out_dir = os.path.normpath( os.path.expanduser(self.out_dir.strip()) ) self.preview = preview # any of the following could return an error as string return self.init_lang(app) or self.check_values() or self.init_files(self.out_dir)
Example #18
Source File: main.py From wxGlade with MIT License | 4 votes |
def __init__(self): version = config.version pos, size, layout = self.init_layout_settings() wx.Frame.__init__(self, None, -1, "wxGlade v%s" % version, pos=pos, size=size, style=wx.DEFAULT_FRAME_STYLE, name='MainFrame') common.main = self self._set_icon() self.create_menu() self.create_toolbar() style = wx.SP_3D | wx.SP_LIVE_UPDATE self.splitter1 = wx.SplitterWindow(self, style=style) self.splitter2 = wx.SplitterWindow(self.splitter1, style=style) self.palette = wxGladePalettePanel(self.splitter2) # create the property and the tree frame common.property_panel = self.property_panel = wxGladePropertyPanel(self.splitter2) common.root = app = application.Application() common.app_tree = self.tree = WidgetTree(self.splitter1, app) self.splitter1.SplitVertically(self.splitter2, self.tree) self.splitter2.SplitHorizontally(self.palette, self.property_panel) self.switch_layout(layout, initial=True) # last visited directory, used on GTK for wxFileDialog self.cur_dir = config.preferences.open_save_path # set a drop target for us... self._droptarget = FileDropTarget(self) self.SetDropTarget(self._droptarget) self.create_statusbar() # create statusbar for display of messages self.Show() #misc.set_focused_widget(common.root) self.Bind(wx.EVT_CLOSE, self.on_close) # disable autosave checks during unittests if config.testing: return self.init_autosave() self.check_autosaved() self.Bind(wx.EVT_CHAR_HOOK, self.on_char_hook) if config.debugging: self.splitter1.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.on_sash) self.splitter2.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.on_sash)
Example #19
Source File: convai_main.py From convai-bot-1337 with GNU General Public License v3.0 | 4 votes |
def start(self): while True: try: res = requests.get(os.path.join(self._bot_url, 'getUpdates'), timeout=5) if res.status_code != 200: logger.warn(res.text) if len(res.json()) == 0: sleep(0.1) continue for m in res.json(): logger.info(m) update = convai_api.ConvUpdate(m) if m['message']['text'].startswith('/start '): self._log_user('_start_or_begin_or_test_cmd', update) greet_user(self._bot, update.effective_chat.id) self._text = m['message']['text'][len('/start '):] self._get_qas() self._add_fsm_and_user(update, True) fsm = self._chat_fsm[update.effective_chat.id] fsm.start_convai() elif m['message']['text'] == '/end': self._log_user('_end_cmd', update) fsm = self._chat_fsm[update.effective_chat.id] fsm.return_to_init() elif m['message']['text'] == 'version': self._log_user('version', update) self._add_fsm_and_user(update) fsm = self._chat_fsm[update.effective_chat.id] fsm._send_message("Version is {}".format(version)) elif m['message']['text'].startswith('reset'): self._log_user('reset', update) self._add_fsm_and_user(update, True) fsm = self._chat_fsm[update.effective_chat.id] fsm.return_to_init() fsm.return_to_start() fsm._send_message("Hmm....") else: self._log_user('_echo_cmd', update) fsm = self._chat_fsm[update.effective_chat.id] fsm.set_user_message(update.message.text) if not fsm._text: fsm._send_message('Text is not given. Please try to type /end and /test to reset the state and get text.') continue # Do we need this if else? if fsm.is_asked(): fsm.check_user_answer_on_asked() else: fsm.classify() except Exception as e: logger.exception(str(e)) sleep(0.1)
Example #20
Source File: application.py From wxGlade with MIT License | 4 votes |
def __init__(self): np.PropertyOwner.__init__(self) self.__saved = True # raw value for self.saved property; if True, there are no changes to save self.__filename = None # raw value for the self.filename property; Name of the output XML file # initialise instance properties self.is_template = np.Property(False) # hidden property # name and derived class name, including validation self.name = np.TextPropertyA("app", default_value="") self.klass = np.TextPropertyA("MyApp", default_value="", name="class") self.properties["name"].validation_re = re.compile(r'^[a-zA-Z]+[\w0-9-]*$') self.properties["class"].validation_re = re.compile(r'^[a-zA-Z]+[\w:.0-9-]*$') # generate separate file for each class? labels = [_("Single file"), _("Separate file for each class") ] tooltips = [_("Write all source code in one file"), _("Split source code in one file per class / widget") ] self.multiple_files = np.RadioProperty( config.default_multiple_files, values=[0,1], labels=labels, tooltips=tooltips ) # code indentation: mode and count self.indent_mode = np.RadioProperty( 1, [0,1], ["Tabs","Spaces"], aliases=["tab","space"], columns=2 ) self.indent_amount = np.SpinProperty( config.default_indent_amount, val_range=(1, 100) ) # C++ file extension self.source_extension = np.TextProperty('cpp') self.header_extension = np.TextProperty('h') # output path output_path = config.default_output_path if self.multiple_files else config.default_output_file self.output_path = np.FileNameProperty(output_path, style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) self._update_output_path('python') self.overwrite = np.InvCheckBoxProperty(config.default_overwrite) # YYY self.mark_blocks = np.CheckBoxProperty(True) # output language languages = sorted( common.code_writers.keys() ) labels = [misc.capitalize(s) for s in languages] self.language = np.RadioProperty('python', languages, labels, columns=3) # gettext? self.use_gettext = np.CheckBoxProperty(config.default_use_gettext) # wx Version: string of major dot minor version number version = "%d.%d"%compat.version if not version in self.all_supported_versions: version = "2.8" if version[0]=="2" else "3.0" self.for_version = np.RadioProperty( version, self.all_supported_versions, tooltips=self._VERSION_TOOLTIPS) # encoding encodings = ["UTF-8", "ISO-8859-1", "ISO-8859-15", "CP1252"] # just some common values self.encoding = np.ComboBoxProperty(config.default_encoding, encodings) # top window name for the generated app self.top_window = prop = np.ListBoxProperty("", choices=[]) prop.auto_activated = True self.generate_code = np.ActionButtonProperty(self.generate_code) self.widget = None # always None, just to keep interface to Tree similar to other editors self.children = [] # the toplevel windows self.node = None