當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。