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


Python platform.startswith方法代码示例

本文整理汇总了Python中sys.platform.startswith方法的典型用法代码示例。如果您正苦于以下问题:Python platform.startswith方法的具体用法?Python platform.startswith怎么用?Python platform.startswith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sys.platform的用法示例。


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

示例1: get_browser_config

# 需要导入模块: from sys import platform [as 别名]
# 或者: from sys.platform import startswith [as 别名]
def get_browser_config():
    '''
    Decides what browser selescrape will use.
    '''
    os_browser = { #maps os to a browser
    'linux':'firefox',
    'darwin':'chrome',
    'win32':'chrome'
    }
    for a in os_browser:
        if platform.startswith(a):
            browser =  os_browser[a]
        else:
            browser = 'chrome'
    value = data['dl']['selescrape_browser']
    value = value.lower() if value else value
    if value in ['chrome', 'firefox']:
        browser = value
    return browser 
开发者ID:vn-ki,项目名称:anime-downloader,代码行数:21,代码来源:selescrape.py

示例2: _ui_tabs

# 需要导入模块: from sys import platform [as 别名]
# 或者: from sys.platform import startswith [as 别名]
def _ui_tabs(self):
        """Returns tab widget w/ Playback, Text, MP3s, Advanced."""

        use_icons = not platform.startswith('darwin')
        tabs = QtWidgets.QTabWidget()

        for content, icon, label in [
                (self._ui_tabs_playback, 'player-time', "Playback"),
                (self._ui_tabs_text, 'editclear', "Text"),
                (self._ui_tabs_mp3gen, 'document-new', "MP3s"),
                (self._ui_tabs_windows, 'kpersonalizer', "Windows"),
                (self._ui_tabs_advanced, 'configure', "Advanced"),
        ]:
            if use_icons:
                tabs.addTab(content(), QtGui.QIcon(f'{ICONS}/{icon}.png'),
                            label)
            else:  # active tabs do not display correctly on Mac OS X w/ icons
                tabs.addTab(content(), label)

        tabs.currentChanged.connect(lambda: (tabs.adjustSize(),
                                             self.adjustSize()))
        return tabs 
开发者ID:AwesomeTTS,项目名称:awesometts-anki-addon,代码行数:24,代码来源:configurator.py

示例3: get_default_providers

# 需要导入模块: from sys import platform [as 别名]
# 或者: from sys.platform import startswith [as 别名]
def get_default_providers():
    global platform
    try:
        from .dnspython import DNSPythonProvider
    except ImportError:
        DNSPythonProvider = None

    if platform.startswith('linux'):
        from .linux import ProcfsProvider, Iproute2Provider, IptablesProvider, CheckTunDevProvider
        from .posix import DigProvider, PosixHostsFileProvider
        return dict(
            process = ProcfsProvider,
            route = Iproute2Provider,
            firewall = IptablesProvider,
            dns = DNSPythonProvider or DigProvider,
            hosts = PosixHostsFileProvider,
            prep = CheckTunDevProvider,
        )
    elif platform.startswith('darwin'):
        from .mac import PsProvider, BSDRouteProvider
        from .posix import PosixHostsFileProvider
        from .dnspython import DNSPythonProvider
        return dict(
            process = PsProvider,
            route = BSDRouteProvider,
            dns = DNSPythonProvider or DigProvider,
            hosts = PosixHostsFileProvider,
        )
    else:
        return dict(
            platform = OSError('Your platform, {}, is unsupported'.format(platform))
        ) 
开发者ID:dlenski,项目名称:vpn-slice,代码行数:34,代码来源:__main__.py

示例4: get_cache_dir

# 需要导入模块: from sys import platform [as 别名]
# 或者: from sys.platform import startswith [as 别名]
def get_cache_dir():
    if platform.startswith('linux'):
        cache_dir = '~/.cache/importmagic/'
    elif platform == 'darwin':
        cache_dir = '~/Library/Caches/importmagic'
    elif platform in ('win32', 'cygwin'):
        cache_dir = '%APPDATA%\importmagic'

    cache_dir = os.path.expanduser(cache_dir)
    if not os.path.exists(cache_dir):
        os.makedirs(cache_dir)

    return cache_dir 
开发者ID:alecthomas,项目名称:importmagic,代码行数:15,代码来源:util.py

示例5: lazy_load_font

# 需要导入模块: from sys import platform [as 别名]
# 或者: from sys.platform import startswith [as 别名]
def lazy_load_font(font_size=default_font_size):
    """
    Lazy loading font according to system platform
    """
    if font_size not in _font_cache:
        if _platform.startswith("darwin"):
            font_path = "/Library/Fonts/Arial.ttf"
        elif _platform.startswith("linux"):
            font_path = "/usr/share/fonts/truetype/ubuntu-font-family/UbuntuMono-R.ttf"
        elif _platform.startswith("win32"):
            font_path = "C:\\Windows\\Fonts\\arial.ttf"
        _font_cache[font_size] = ImageFont.truetype(font_path, font_size)
    return _font_cache[font_size] 
开发者ID:HazyResearch,项目名称:pdftotree,代码行数:15,代码来源:img_utils.py

示例6: __init__

# 需要导入模块: from sys import platform [as 别名]
# 或者: from sys.platform import startswith [as 别名]
def __init__(self):
    self.arrow=None
    super(handleDialog,self).__init__('disp.ui')
    self.form.edit1.setValidator(QDoubleValidator())
    #self.form.edit1.hide()#
    #self.form.lab1.hide()#
    self.form.btn1.clicked.connect(self.selectAction)
    from sys import platform
    if platform.startswith('win'):
      self.form.lab2.hide() 
开发者ID:oddtopus,项目名称:flamingo,代码行数:12,代码来源:polarUtilsCmd.py

示例7: __init__

# 需要导入模块: from sys import platform [as 别名]
# 或者: from sys.platform import startswith [as 别名]
def __init__(self,dialog='anyFile.ui'):
    dialogPath=join(dirname(abspath(__file__)),"dialogs",dialog)
    FreeCAD.Console.PrintMessage(dialogPath+"\n")
    self.form=FreeCADGui.PySideUic.loadUi(dialogPath)
    FreeCAD.Console.PrintMessage(dialogPath+" loaded\n")
    if platform.startswith('win'):# or vQt>=5:
      FreeCAD.Console.PrintWarning("No keyboard shortcuts.\n No callback on SoEvent")
    else:
      FreeCAD.Console.PrintMessage('Keyboard shortcuts available.\n"S" to select\n"RETURN" to perform action\n')
      try:
        self.view=FreeCADGui.activeDocument().activeView() # get3DView()
        self.call=self.view.addEventCallback("SoEvent", self.action)
      except:
        FreeCAD.Console.PrintError('No view available.\n') 
开发者ID:oddtopus,项目名称:flamingo,代码行数:16,代码来源:frameForms.py

示例8: _get_pressed_shortcut_buttons

# 需要导入模块: from sys import platform [as 别名]
# 或者: from sys.platform import startswith [as 别名]
def _get_pressed_shortcut_buttons(self):
        """Returns all shortcut buttons that are pressed."""

        return [button
                for button in self.findChildren(QtWidgets.QPushButton)
                if (button.isChecked() and
                    (button.objectName().startswith('launch_') or
                     button.objectName().startswith('tts_key_')))] 
开发者ID:AwesomeTTS,项目名称:awesometts-anki-addon,代码行数:10,代码来源:configurator.py

示例9: externalDriveManager

# 需要导入模块: from sys import platform [as 别名]
# 或者: from sys.platform import startswith [as 别名]
def externalDriveManager():
	global _instance

	if _instance is None:
		if platform.startswith("linux"):
			from .linux import ExternalDriveManager
			_instance = ExternalDriveManager()

		elif platform == "darwin":
			from .mac_dev import ExternalDriveManager
			_instance = ExternalDriveManager()

	return _instance 
开发者ID:AstroPrint,项目名称:AstroBox,代码行数:15,代码来源:__init__.py

示例10: test_anon_unix

# 需要导入模块: from sys import platform [as 别名]
# 或者: from sys.platform import startswith [as 别名]
def test_anon_unix(self):
        if platform.startswith("linux"):
            self.do_run("unix:@org.varlink.service_anon_test"
                        + str(os.getpid())
                        + threading.current_thread().getName()
                        ) 
开发者ID:varlink,项目名称:python,代码行数:8,代码来源:test_basic_network.py

示例11: add_file

# 需要导入模块: from sys import platform [as 别名]
# 或者: from sys.platform import startswith [as 别名]
def add_file(self, file):
        if file.startswith(self.name + '/'):
            file = file.replace(self.name + '/', '', 1)

        if '/' in file:
            # This file is in a subdir
            subdir = file.split('/')[0]
            if subdir in self.subdirs:
                self.subdirs[subdir].add_file(file)
            else:
                self.subdirs[subdir] = Dir(os.path.join(self.fullpath, subdir))
                self.subdirs[subdir].add_file(file)
        else:
            self.files.append(file)
        return True 
开发者ID:azlux,项目名称:botamusique,代码行数:17,代码来源:util.py

示例12: get_url_from_input

# 需要导入模块: from sys import platform [as 别名]
# 或者: from sys.platform import startswith [as 别名]
def get_url_from_input(string):
    string = string.strip()
    if not (string.startswith("http") or string.startswith("HTTP")):
        res = re.search('href="(.+?)"', string, flags=re.IGNORECASE)
        if res:
            string = res.group(1)
        else:
            return False

    match = re.search("(http|https)://(\S*)?/(\S*)", string, flags=re.IGNORECASE)
    if match:
        url = match[1].lower() + "://" + match[2].lower() + "/" + match[3]
        return url
    else:
        return False 
开发者ID:azlux,项目名称:botamusique,代码行数:17,代码来源:util.py

示例13: toast_notification

# 需要导入模块: from sys import platform [as 别名]
# 或者: from sys.platform import startswith [as 别名]
def toast_notification(notify, alert, job, interval):
    """ Send toast notifications about supervising states directly to OS
    using 'plyer' module """
    platform_matches = platform.startswith(("win32", "linux", "darwin"))
    if notify is True and platform_matches:
        icons = get_icons()
        delay = 9 if alert == "exit" else 7
        label = job.replace("_", " ").capitalize()

        expr = (
            "Yawn! {} filled {} quotient!\t~falling asleep a little bit :>"
            if alert == "sleep"
            else "Yikes! {} just woke up from {} quotient bandage!\t~let's "
            "chill again wakey ;)"
            if alert == "wakeup"
            else "D'oh! {} finished {} quotient!\t~exiting ~,~"
        )

        try:
            notification.notify(
                title="Quota Supervisor",
                message=expr.format(label, interval),
                app_name="InstaPy",
                app_icon=icons[alert],
                timeout=delay,
                ticker="To switch supervising methods, please review "
                "quickstart script",
            )

        except Exception:
            # TypeError: out of 'plyer' bug in python 2 - INNER EXCEPTION
            # NotImplementedError: when 'plyer' is not supported
            # DBusException: dbus-display issue on linux boxes

            # turn off toast notification for the rest of the session
            configuration.update(nofity=False) 
开发者ID:Instagram-Tools,项目名称:bot,代码行数:38,代码来源:quota_supervisor.py

示例14: get_icons

# 需要导入模块: from sys import platform [as 别名]
# 或者: from sys.platform import startswith [as 别名]
def get_icons():
    """ Return the locations of icons according to the operating system """
    # get full location of icons folder inside package
    icons_path = get_pkg_resource_path("instapy", "icons/")

    windows_ico = [
        "Windows/qs_sleep_windows.ico",
        "Windows/qs_wakeup_windows.ico",
        "Windows/qs_exit_windows.ico",
    ]
    linux_png = [
        "Linux/qs_sleep_linux.png",
        "Linux/qs_wakeup_linux.png",
        "Linux/qs_exit_linux.png",
    ]
    mac_icns = [
        "Mac/qs_sleep_mac.icns",
        "Mac/qs_wakeup_mac.icns",
        "Mac/qs_exit_mac.icns",
    ]

    # make it full path now
    windows_ico = [icons_path + icon for icon in windows_ico]
    linux_png = [icons_path + icon for icon in linux_png]
    mac_icns = [icons_path + icon for icon in mac_icns]

    (sleep_icon, wakeup_icon, exit_icon) = (
        windows_ico
        if platform.startswith("win32")
        else linux_png
        if platform.startswith("linux")
        else mac_icns
        if platform.startswith("darwin")
        else [None, None, None]
    )

    icons = {"sleep": sleep_icon, "wakeup": wakeup_icon, "exit": exit_icon}

    return icons 
开发者ID:Instagram-Tools,项目名称:bot,代码行数:41,代码来源:quota_supervisor.py

示例15: test_chars

# 需要导入模块: from sys import platform [as 别名]
# 或者: from sys.platform import startswith [as 别名]
def test_chars():
    bullet = "►" if platform.startswith("win") else "❱"
    tty.verbose = False
    tty.no_style = False
    expected = {
        "arrow": f"\x1b[35m{bullet}\x1b[0m",
        "block": "█",
        "left-edge": "▐",
        "right-edge": "▌",
        "selected": "●",
        "unselected": "○",
    }
    actual = tty._chars()
    assert actual == expected 
开发者ID:jkwill87,项目名称:mnamer,代码行数:16,代码来源:test_tty.py


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