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


Python path.pardir方法代码示例

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


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

示例1: test_toolchain_standard_build_dir_remapped

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import pardir [as 别名]
def test_toolchain_standard_build_dir_remapped(self):
        """
        This can either be caused by relative paths or symlinks.  Will
        result in the manually specified build_dir being remapped to its
        real location
        """

        fake = mkdtemp(self)
        real = mkdtemp(self)
        real_base = basename(real)
        spec = Spec()
        spec['build_dir'] = join(fake, pardir, real_base)

        with pretty_logging(stream=StringIO()) as s:
            with self.assertRaises(NotImplementedError):
                self.toolchain(spec)

        self.assertIn("realpath of 'build_dir' resolved to", s.getvalue())
        self.assertEqual(spec['build_dir'], real) 
开发者ID:calmjs,项目名称:calmjs,代码行数:21,代码来源:test_toolchain.py

示例2: getComment

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import pardir [as 别名]
def getComment(request):
        pass
        # if request.method == "GET":
        # text = request.GET.get("commentId")
        # resp = list(Target.objects.values('uid', 'cookie', 'add_time'))
        # uid = int(resp[0]["uid"])
        # cookie = {"Cookie": resp[0]["cookie"]}
        # wb = Weibo(uid,cookie)
        # print("数据库不存在该评论,正在爬虫生成")
        # mm = wb.get_comment_info(text)


      
# Create your tests here.
# with urllib.request.urlopen("https://wx2.sinaimg.cn/large/" + '893ea4cely1g2kbqkzuzyj21hc0u0q9p', timeout=30) as response, open("893ea4cely1g2kbqkzuzyj21hc0u0q9p.jpg", 'wb') as f_save:
#     f_save.write(response.read())
#     f_save.flush()
#     f_save.close()
# print (path.dirname(path.abspath("__file__")))
# print (path.pardir)
# print (path.join(path.dirname("__file__"),path.pardir))
# print (path.abspath(path.join(path.dirname("__file__"),path.pardir)))
# print (path.abspath(path.join(os.getcwd(), "../../webview/static/"))) 
开发者ID:Superbsco,项目名称:weibo-analysis-system,代码行数:25,代码来源:tests.py

示例3: test

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import pardir [as 别名]
def test():
    """
    Run widget test.

    Show the unittest widgets, configured so that our own tests are run when
    the user clicks "Run tests".
    """
    from spyder.utils.qthelpers import qapplication
    app = qapplication()
    widget = UnitTestWidget(None)

    # set wdir to .../spyder_unittest
    wdir = osp.abspath(osp.join(osp.dirname(__file__), osp.pardir))
    widget.config = Config('pytest', wdir)

    # add wdir's parent to python path, so that `import spyder_unittest` works
    rootdir = osp.abspath(osp.join(wdir, osp.pardir))
    widget.pythonpath = [rootdir]

    widget.resize(800, 600)
    widget.show()
    sys.exit(app.exec_()) 
开发者ID:spyder-ide,项目名称:spyder-unittest,代码行数:24,代码来源:unittestgui.py

示例4: _load_data

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import pardir [as 别名]
def _load_data():
    """Load the data from the csv in data.

    The "gene_id" is the Entrez gene id, and the "approved_symbol" is the
    standard gene symbol. The "hms_id" is the LINCS ID for the drug.

    Returns
    -------
    data : list[dict]
        A list of dicts of row values keyed by the column headers extracted from
        the csv file, described above.
    """
    # Get the cwv reader object.
    csv_path = path.join(HERE, path.pardir, path.pardir, 'resources',
                         DATAFILE_NAME)
    data_iter = list(read_unicode_csv(csv_path))

    # Get the headers.
    headers = data_iter[0]

    # For some reason this heading is oddly formatted and inconsistent with the
    # rest, or with the usual key-style for dicts.
    headers[headers.index('Approved.Symbol')] = 'approved_symbol'
    return [{header: val for header, val in zip(headers, line)}
            for line in data_iter[1:]] 
开发者ID:sorgerlab,项目名称:indra,代码行数:27,代码来源:api.py

示例5: find_package_name_dir_up

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import pardir [as 别名]
def find_package_name_dir_up(parent_path):
    for file_name in listdir(parent_path):
        if isdir(file_name):
            continue

        if file_name == 'AndroidManifest.xml':
            for line in open(join(parent_path, file_name), 'r'):
                package_name_re_result = PACKAGE_NAME_RE.search(line)
                if package_name_re_result is not None:
                    return package_name_re_result.groups()[0]

        if file_name == 'build.gradle':
            for line in open(join(parent_path, file_name), 'r'):
                application_id_re_result = APPLICATION_ID_RE.search(line)
                if application_id_re_result is not None:
                    return application_id_re_result.groups()[0]

    return find_package_name_dir_up(abspath(join(parent_path, pardir))) 
开发者ID:Jacksgong,项目名称:android-project-combine,代码行数:20,代码来源:res_utils.py

示例6: __init__

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import pardir [as 别名]
def __init__(self):
        super(_HomeTab, self).__init__()

        self._layout = QHBoxLayout()
        self.setLayout(self._layout)

        message_label = QLabel("""\
        Welcome to <b>EvilOSX</b>:<br/>
        An evil RAT (Remote Administration Tool) for macOS / OS X.<br/><br/><br/>

        Author: Marten4n6<br/>
        License: GPLv3<br/>
        Version: <b>{}</b>
        """.format(VERSION))
        logo_label = QLabel()

        logo_path = path.join(path.dirname(__file__), path.pardir, path.pardir, "data", "images", "logo_334x600.png")
        logo_label.setPixmap(QPixmap(logo_path))

        self._layout.setAlignment(Qt.AlignCenter)
        self._layout.setSpacing(50)
        self._layout.addWidget(message_label)
        self._layout.addWidget(logo_label) 
开发者ID:Marten4n6,项目名称:EvilOSX,代码行数:25,代码来源:gui.py

示例7: wrap_loader

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import pardir [as 别名]
def wrap_loader(loader_name, loader_options, payload):
        """:return: The loader which will load the (configured and encrypted) payload.

        :type loader_name: str
        :type loader_options: dict
        :type payload: str
        :rtype: str
        """
        loader_path = path.realpath(path.join(
            path.dirname(__file__), path.pardir, "bot", "loaders", loader_name, "install.py")
        )
        loader = ""

        with open(loader_path, "r") as input_file:
            for line in input_file:
                if line.startswith("LOADER_OPTIONS = "):
                    loader += "LOADER_OPTIONS = {}\n".format(str(loader_options))
                elif line.startswith("PAYLOAD_BASE64 = "):
                    loader += "PAYLOAD_BASE64 = \"{}\"\n".format(b64encode(payload.encode()).decode())
                else:
                    loader += line

        return loader 
开发者ID:Marten4n6,项目名称:EvilOSX,代码行数:25,代码来源:model.py

示例8: build_incident_dto

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import pardir [as 别名]
def build_incident_dto(self, headers, case_id):
        current_path = os.path.dirname(os.path.realpath(__file__))
        default_temp_file = join(current_path, pardir, "data/templates/esm_incident_mapping.jinja")
        template_file = self.options.get("incident_template", default_temp_file)

        try:
            with open(template_file, 'r') as template:
                log.debug("Reading template file")

                case_details = case_get_case_detail(self.options, headers, case_id)
                log.debug("Case details in dict form: {}".format(case_details))

                incident_template = template.read()

                return template_functions.render(incident_template, case_details)

        except jinja2.exceptions.TemplateSyntaxError:
            log.info("'incident_template' is not set correctly in config file.") 
开发者ID:ibmresilient,项目名称:resilient-community-apps,代码行数:20,代码来源:mcafee_esm_case_polling.py

示例9: build_incident_dto

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import pardir [as 别名]
def build_incident_dto(alert, custom_temp_file=None):
    current_path = os.path.dirname(os.path.realpath(__file__))
    if custom_temp_file:
        template_file = custom_temp_file
    else:
        default_temp_file = join(current_path, pardir, "data/templates/msg_incident_mapping.jinja")
        template_file = default_temp_file

    try:
        with open(template_file, 'r') as template:
            log.debug("Reading template file")
            incident_template = template.read()

            return template_functions.render(incident_template, alert)

    except jinja2.exceptions.TemplateSyntaxError:
        log.info("'incident_template' is not set correctly in config file.") 
开发者ID:ibmresilient,项目名称:resilient-community-apps,代码行数:19,代码来源:microsoft_security_graph_alerts_integrations.py

示例10: split_template_path

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import pardir [as 别名]
def split_template_path(template):
    """Split a path into segments and perform a sanity check.  If it detects
    '..' in the path it will raise a `TemplateNotFound` error.
    """
    pieces = []
    for piece in template.split('/'):
        if path.sep in piece \
           or (path.altsep and path.altsep in piece) or \
           piece == path.pardir:
            raise TemplateNotFound(template)
        elif piece and piece != '.':
            pieces.append(piece)
    return pieces 
开发者ID:remg427,项目名称:misp42splunk,代码行数:15,代码来源:loaders.py

示例11: fileTransferHelper

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import pardir [as 别名]
def fileTransferHelper(srclist, dest):
    """
    Pass in list of paths to file, and copy to root destination
    It will create patch's parent folder if not already exist in the destination folder
    For example:
        fileTransferHelper(["..../OP1_File_Organizer/NotUsed/..../patch.aif"], dest = "/..../synth")

    :param srclist: ["pwd/1.aif", "pwd/2.aif", "pwd/3.aif",....., "pwd/n.aif"]
    :param dest: Root of the synth and drum destination folder
    :return: NA
    """

    for i in srclist:
        srcParentFolderName = abspath(join(i, pardir)).split("/")[-1:][0]
        srcBaseName = basename(i)
        distParentFolderName = dest + "/" + str(srcParentFolderName)
        print(distParentFolderName)
        forcedir(distParentFolderName)
        image = Image.new('1', (128, 64))

        if workDir in srclist[0]:
            # Local to OP1
            image.paste(Image.open(workDir + "/Assets/Img/UploadPatches.png").convert("1"))
        else:
            # OP1 to Local
            image.paste(Image.open(workDir + "/Assets/Img/DownloadPatches.png").convert("1"))
        draw = ImageDraw.Draw(image)
        draw.text((20, 63), srcBaseName, font=GPIO_Init.getFont(), fill="white")
        GPIO_Init.displayImage(image)
        print(i, distParentFolderName + "/" + srcBaseName)
        shutil.copy2(i, distParentFolderName + "/" + srcBaseName)

    GPIO_Init.displayPng(workDir + "/Assets/Img/Done.png")
    GPIO_Init.getAnyKeyEvent()  # Press any key to proceed
    return 
开发者ID:adwuard,项目名称:OP_Manager,代码行数:37,代码来源:file_util.py

示例12: get_includes

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import pardir [as 别名]
def get_includes():
    """Return a list of directories to include for linking against pyzmq with cython."""
    from os.path import join, dirname, abspath, pardir, exists
    base = dirname(__file__)
    parent = abspath(join(base, pardir))
    includes = [ parent ] + [ join(parent, base, subdir) for subdir in ('utils',) ]
    if exists(join(parent, base, 'include')):
        includes.append(join(parent, base, 'include'))
    return includes 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:11,代码来源:__init__.py

示例13: get_library_dirs

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import pardir [as 别名]
def get_library_dirs():
    """Return a list of directories used to link against pyzmq's bundled libzmq."""
    from os.path import join, dirname, abspath, pardir
    base = dirname(__file__)
    parent = abspath(join(base, pardir))
    return [ join(parent, base) ] 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:8,代码来源:__init__.py

示例14: get_includes

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import pardir [as 别名]
def get_includes():
    """Return a list of directories to include for linking against pyzmq with cython."""
    from os.path import join, dirname, abspath, pardir
    base = dirname(__file__)
    parent = abspath(join(base, pardir))
    return [ parent ] + [ join(parent, base, subdir) for subdir in ('utils',) ] 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:8,代码来源:__init__.py

示例15: __init__

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import pardir [as 别名]
def __init__(self, path_app):
        super().__init__()
        self.title('Extended PyGISS')
        path_icon = abspath(join(path_app, pardir, 'images'))
        
        # generate the PSF tk images
        img_psf = ImageTk.Image.open(join(path_icon, 'node.png'))
        selected_img_psf = ImageTk.Image.open(join(path_icon, 'selected_node.png'))
        self.psf_button_image = ImageTk.PhotoImage(img_psf.resize((100, 100)))
        self.node_image = ImageTk.PhotoImage(img_psf.resize((40, 40)))
        self.selected_node_image = ImageTk.PhotoImage(selected_img_psf.resize((40, 40)))

        for widget in (
                       'Button',
                       'Label', 
                       'Labelframe', 
                       'Labelframe.Label', 
                       ):
            ttk.Style().configure('T' + widget, background='#A1DBCD')

        self.map = Map(self)
        self.map.pack(side='right', fill='both', expand=1)

        self.menu = Menu(self)
        self.menu.pack(side='right', fill='both', expand=1)

        menu = tk.Menu(self)
        menu.add_command(label="Import shapefile", command=self.map.import_map)
        self.config(menu=menu)

        # if motion is called, the left-click button was released and we 
        # can stop the drag and drop process
        self.bind_all('<Motion>', self.stop_drag_and_drop)
        self.drag_and_drop = False

        self.image = None
        self.bind_all('<B1-Motion>', lambda _:_) 
开发者ID:afourmy,项目名称:pyGISS,代码行数:39,代码来源:extended_pyGISS.py


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