当前位置: 首页>>代码示例>>Python>>正文


Python options.Options类代码示例

本文整理汇总了Python中options.Options的典型用法代码示例。如果您正苦于以下问题:Python Options类的具体用法?Python Options怎么用?Python Options使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Options类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_prefs_data

 def _get_prefs_data(self, req, opts=None):
     """Returns the pref data, a dict of rule class titles whose values
     include lists of rule spec preference dicts each with these keys:
     
       id (based on unique key)
       label (of checkbox)
       enabled ('1' or '0')
       type ('none', 'select', or 'text') 
       options (list of options if type is 'select')
       value (saved preference or default value)
     """
     if opts is None:
         opts = Options(self.env)
     data = {}
     for rule in self.rules:
         for key in opts:
             if not opts.has_pref(key):
                continue
             target_re = re.compile(r"(?P<target>[^.]+).*")
             target = target_re.match(key).groupdict()['target']
             trigger = rule.get_trigger(req, target, key, opts)
             if not trigger:
                 continue
             
             # this rule spec has a pref - so get it!
             pref = opts.get_pref(req, target, key)
             rule.update_pref(req, trigger, target, key, opts, pref)
             data.setdefault(rule.title,{'desc':rule.desc,'prefs':[]})
             data[rule.title]['prefs'].append(pref)
     return data
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:30,代码来源:web_ui.py

示例2: fill_option_data

def fill_option_data(frame):
    """
    This collects all call options data near the stock price.

    NOTE
    ----
    If this breaks in the options data it is beacuse I changed the file.
    in my pandas installation. See the class in the local options.py.
    """
    ticks = frame.index

    out = pd.DataFrame()

    for tick in range(1, ticks.size):
        try:
            new = Options(ticks[tick]).get_forward_data(plus, call=True,
                                                        put=False, near=True,
                                                        above_below=2)
            new.index = [ticks[tick]] * new.index.size
            cat = new[['Strike', 'Expiry', 'Last', 'Vol', 'Open Int']]
            out = pd.concat([out, cat])
        except:
            pass

    return out
开发者ID:spencerlyon2,项目名称:pytools,代码行数:25,代码来源:covered_call.py

示例3: __init__

    def __init__(self, executable_path="chromedriver", port=0,
                 chrome_options=None, service_args=None,
                 desired_capabilities=None):
        """
        Creates a new instance of the chrome driver.

        Starts the service and then creates new instance of chrome driver.

        :Args:
         - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH
         - port - port you would like the service to run, if left as 0, a free port will be found.
         - desired_capabilities: Dictionary object with non-browser specific
           capabilities only, such as "proxy" or "loggingPref".
         - chrome_options: this takes an instance of ChromeOptions
        """
        if chrome_options is None:
            options = Options()
        else:
            options = chrome_options

        if desired_capabilities is not None:
          desired_capabilities.update(options.to_capabilities())
        else:
          desired_capabilities = options.to_capabilities()

        self.service = Service(executable_path, port=port, service_args=service_args)
        self.service.start()

        try:
            RemoteWebDriver.__init__(self,
                command_executor=self.service.service_url,
                desired_capabilities=desired_capabilities)
        except:
            self.quit()
            raise 
开发者ID:Atala,项目名称:META-SHARE,代码行数:35,代码来源:webdriver.py

示例4: find_log_file

    def find_log_file(self, wdir_prefix=".."):
        """
        Try to find the game log file
        Returns a string path, or None if we couldn't find it
        """
        logfile_location = ""
        version_path_fragment = Options().game_version
        if version_path_fragment == "Antibirth":
            version_path_fragment = "Rebirth"

        if platform.system() == "Windows":
            logfile_location = os.environ['USERPROFILE'] + '/Documents/My Games/Binding of Isaac {}/'
        elif platform.system() == "Linux":
            logfile_location = os.getenv('XDG_DATA_HOME',
                                         os.path.expanduser('~') + '/.local/share') + '/binding of isaac {}/'
            version_path_fragment = version_path_fragment.lower()
        elif platform.system() == "Darwin":
            logfile_location = os.path.expanduser('~') + '/Library/Application Support/Binding of Isaac {}/'

        logfile_location = logfile_location.format(version_path_fragment)

        for check in (wdir_prefix + '../log.txt', logfile_location + 'log.txt'):
            if os.path.isfile(check):
                return check

        self.log.error("Couldn't find log.txt in " + logfile_location)
        return None
开发者ID:Zamiell,项目名称:RebirthItemTracker,代码行数:27,代码来源:log_finder.py

示例5: download_file

 def download_file(self, url, path):
     ''' Downloads an single url. '''
     o = Options()
     o.add_option('--output-document', path)
     self.url = url
     self.prepare_command(o)
     self._download_file(url, path)
开发者ID:tomb7890,项目名称:pycatcher,代码行数:7,代码来源:downloader.py

示例6: __init__

 def __init__(self):
     from cli_options_parser import parser
     
     Options.__init__(self)
     opts, args = parser.parse_args()
     self.options = opts.__dict__
     self.options['path'] = [os.path.normpath(path) for path in args]
开发者ID:enaydanov,项目名称:pypumber,代码行数:7,代码来源:cli_options.py

示例7: __init__

    def __init__(self, executable_path="chromedriver", port=0,
                 desired_capabilities=None, chrome_options=None):
        """
        Creates a new instance of the chrome driver.

        Starts the service and then creates new instance of chrome driver.

        :Args:
         - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH
         - port - port you would like the service to run, if left as 0, a free port will be found.
         - desired_capabilities: Dictionary object with desired capabilities (Can be used to provide various chrome
           switches). This is being deprecated, please use chrome_options
         - chrome_options: this takes an instance of ChromeOptions
        """
        if chrome_options is None:
            options = Options()
        else:
            options = chrome_options

        if desired_capabilities is not None:
            warnings.warn("Desired Capabilities has been deprecated, please user chrome_options.", DeprecationWarning)
            desired_capabilities.update(options.to_capabilities())
        else:
            desired_capabilities = options.to_capabilities()

        self.service = Service(executable_path, port=port)
        self.service.start()

        try:
            RemoteWebDriver.__init__(self,
                command_executor=self.service.service_url,
                desired_capabilities=desired_capabilities)
        except:
            self.quit()
            raise WebDriverException("The Driver was not able to start.")
开发者ID:andersroos,项目名称:selenium-chat-example,代码行数:35,代码来源:webdriver.py

示例8: download_new_files

 def download_new_files(self, downloader, episodes):
     logging.info("Subscriptions.download_new_files")
     queue = self.prepare_queue(episodes)
     if len(queue) > 0:
         o = Options()
         o.add_option('--directory-prefix', self._data_subdir())
         if self.limitrate:
             o.add_option('--limit-rate',
                                   self.limitrate)
         downloader.download_queue(queue, o)
开发者ID:tomb7890,项目名称:pycatcher,代码行数:10,代码来源:subscriptions.py

示例9: load_options

 def load_options(self):
     #realkeydict
     self.rkd = {}
     options = Options()
     for dkey, rkey in options.iteritems():
         try:
             self.rkd[dkey] = key.__getattribute__(rkey)
         except AttributeError:
             if rkey == 'M1':
                 self.rkd[dkey] = 1 + self.mouse_offset
开发者ID:ashisdhara,项目名称:python_game,代码行数:10,代码来源:controls.py

示例10: __init__

 def __init__(self, profile='default'):
     Options.__init__(self)
     
     if _PROFILES is not None:
         try:
             opts, args = parser.parse_args(shlex.split(_PROFILES[profile]))
             self.options = opts.__dict__
             self.options['path'] = args
         except KeyError:
             if profile != 'default':
                 sys.stderr.write("Error: there is no profile with name '%s'\n" % profile)
                 sys.exit()
开发者ID:enaydanov,项目名称:pypumber,代码行数:12,代码来源:profile_options.py

示例11: ctmain

def ctmain():
    utils.fix_output_encoding()
    settings = ComicTaggerSettings()

    opts = Options()
    opts.parseCmdLineArgs()

    # manage the CV API key
    if opts.cv_api_key:
        if opts.cv_api_key != settings.cv_api_key:
            settings.cv_api_key = opts.cv_api_key
            settings.save()
    if opts.only_set_key:
        print("Key set")
        return

    ComicVineTalker.api_key = settings.cv_api_key

    signal.signal(signal.SIGINT, signal.SIG_DFL)

    if not qt_available and not opts.no_gui:
        opts.no_gui = True
        print >> sys.stderr, "PyQt4 is not available.  ComicTagger is limited to command-line mode."

    if opts.no_gui:
        cli.cli_mode(opts, settings)
    else:
        app = QtGui.QApplication(sys.argv)

        if platform.system() != "Linux":
            img = QtGui.QPixmap(ComicTaggerSettings.getGraphic('tags.png'))

            splash = QtGui.QSplashScreen(img)
            splash.show()
            splash.raise_()
            app.processEvents()

        try:
            tagger_window = TaggerWindow(opts.file_list, settings, opts=opts)
            tagger_window.show()

            if platform.system() != "Linux":
                splash.finish(tagger_window)

            sys.exit(app.exec_())
        except Exception as e:
            QtGui.QMessageBox.critical(
                QtGui.QMainWindow(),
                "Error",
                "Unhandled exception in app:\n" +
                traceback.format_exc())
开发者ID:Kalinon,项目名称:comictagger,代码行数:51,代码来源:main.py

示例12: __init__

    def __init__(self):
        super().__init__()
   
        self.option_add("*tearOff", FALSE)
        self.initialized = False
        self.title("Papyer")
        
        x, y = 1500, 500
        self.minsize(x, y)
        placeWindow(self, x, y)
        
        self.options = Options(self)
        self["menu"] = TopMenu(self)        

        self.protocol("WM_DELETE_WINDOW", self.closeFun)

        self.base = os.getcwd()

        self.selectVar = StringVar()
        self.searchVar = StringVar()

        self.createWidgets()

        self.columnconfigure(1, weight = 1)
        self.columnconfigure(3, weight = 1)
        self.columnconfigure(5, weight = 1)
        self.rowconfigure(4, weight = 1)

        self.bind("<Control-d>", lambda e: self.filetree.keepDuplicates())
        self.bind("<Control-a>", lambda e: self.filetree.selectAll())
        
        self.mainloop()
开发者ID:bahniks,项目名称:PaPyer,代码行数:32,代码来源:starter.py

示例13: PyvisdkApp

class PyvisdkApp(object):
    '''
    Base class implementation of a command line application.  See the :py:mod:`~pyvisdk.app` module for documentation on the format of the options file.
    '''


    def __init__(self, usage=None):
        '''
        Constructor
        '''
        self.options = Options()
        if not usage:
            usage = "usage: %prog [options]"
        self.parser = OptionParser(usage=usage)
        self.parser.add_option("-c", "--config", dest="VI_CONFIG", help="Specify non-default name or location for the VI Perl Toolkit configuration file. Default name and location for Linux is ~/.visdkrc and for Windows is %HOME%\visdk.rc.")
        self.parser.add_option("-p", "--password", dest="VI_PASSWORD", help="Password for the specified username. Sucessful authentication with username and password returns a session object that can be saved and used for subsequent connections using the same or different script. See sessionfile.")
        self.parser.add_option("--portnumber", dest="VI_PORTNUMBER", help="Port used for server connection.")
        self.parser.add_option("--protocol", dest="VI_PROTOCOL", help="Protocol used to connect to server. Default is HTTPS. If the server has been configured for HTTP, set to HTTP. ")
        self.parser.add_option("-s", "--server", dest="VI_SERVER", help="ESX Server or VirtualCenter Management Server host to which you want the application or script to connect. Default is localhost if none specified.")
        self.parser.add_option("--servicepath", dest="VI_SERVICEPATH", help="Service path for server connection. Default is /sdk/webService.")
        self.parser.add_option("--sessionfile", dest="VI_SESSIONFILE", help="Name of file containing the token saved from successful login. Alternative to specifying username and password. Sessions time out after 30 minutes of inactivity.")
        self.parser.add_option("--url", dest="VI_URL", help="Complete URL for SDK connection. An alternative to specifying protocol, server, and servicepath as individual connection parameters. For example, python app_name.py --url https://myserver.mycompany.com/sdk --username root --password mypassword")
        self.parser.add_option("-u", "--username", dest="VI_USERNAME", help="User account that has privileges to connect to the server.")
        self.parser.add_option("-v", "--verbose", dest="VI_VERBOSE", help="Increase loglevel. Use in conjunction with Util::trace subroutine to display additional debugging information. By default, value of --verbose (loglevel) is 0. ")
        self.parser.add_option("-V", "--version", help="Displays script version information, if available.")
        
    def parse(self):
        (cmd_opts, _) = self.parser.parse_args(sys.argv[1:]) # IGNORE W0201
        
        # load up options from the visdkrc file if there is any
        if cmd_opts.VI_CONFIG:
            self.options.load(cmd_opts.VI_CONFIG)
        else:
            self.options.load()
            
        # also, update options with environmental values, overriding those in the configuration file.
        self.options.load_env()
            
        # update our options with what was entered on the command line.  This will override previously
        # entered options
        for name, value in cmd_opts.__dict__.items():
            if value:
                self.options.update({name:value})
        
        # need to have server, username, and password or fail
        if not (self.options.VI_USERNAME and self.options.VI_PASSWORD and self.options.VI_SERVER):
            raise RuntimeError("Must specify --username, --password and --server")


    def connect(self):
        self.vim = Vim(self.options.VI_SERVER)
        self.vim.login(self.options.VI_USERNAME, self.options.VI_PASSWORD)
    
    def disconnect(self):
        self.vim.logout()
开发者ID:Infinidat,项目名称:pyvisdk,代码行数:55,代码来源:app.py

示例14: userFolder

    def userFolder():
        opts = Options()
        opts.parseCmdLineArgs(False)
        
        filename_encoding = sys.getfilesystemencoding()

        if opts.user_dir is not None:
            folder = opts.user_dir
        elif platform.system() == "Windows":
            folder = os.path.join( AppFolders.windowsAppDataFolder(), appname )
        elif platform.system() == "Darwin":
            folder = os.path.join( os.path.expanduser('~') , 'Library/Application Support/'+appname)
        else:
            folder = os.path.join( os.path.expanduser('~') , '.'+appname)
            
        if folder is not None:
            folder = folder.decode(filename_encoding)
        return folder
开发者ID:Tristan79,项目名称:ComicStreamer,代码行数:18,代码来源:folders.py

示例15: userFolder

    def userFolder():

        opts = Options()
        opts.parseCmdLineArgs()

        filename_encoding = sys.getfilesystemencoding()

        if opts.user_dir is not None:
            folder = opts.user_dir
        elif platform.system() == "Windows":
            folder = os.path.join(AppFolders.windowsAppDataFolder(), "ComicStreamer")
        elif platform.system() == "Darwin":
            folder = os.path.join(os.path.expanduser("~"), "Library/Application Support/ComicStreamer")
        else:
            folder = os.path.join(os.path.expanduser("~"), ".ComicStreamer")

        if folder is not None:
            folder = folder.decode(filename_encoding)
        return folder
开发者ID:Kalinon,项目名称:ComicStreamer,代码行数:19,代码来源:folders.py


注:本文中的options.Options类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。