當前位置: 首頁>>代碼示例>>Python>>正文


Python Path.create方法代碼示例

本文整理匯總了Python中moments.path.Path.create方法的典型用法代碼示例。如果您正苦於以下問題:Python Path.create方法的具體用法?Python Path.create怎麽用?Python Path.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在moments.path.Path的用法示例。


在下文中一共展示了Path.create方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_create

# 需要導入模塊: from moments.path import Path [as 別名]
# 或者: from moments.path.Path import create [as 別名]
 def test_create(self):
     p = "create_me.txt"
     path = Path(p)
     assert not os.path.exists(p)
     path.create()
     assert os.path.exists(p)
     path.remove()
     assert not os.path.exists(p)
開發者ID:charlesbrandt,項目名稱:moments,代碼行數:10,代碼來源:test_path.py

示例2: Path

# 需要導入模塊: from moments.path import Path [as 別名]
# 或者: from moments.path.Path import create [as 別名]
don't forget about the old 'contextiskey.com' site...
it's a bit more higher level
in its description of essentially starting a new journal 'context'
these notes have been merged in with my personal sites directory
(or available publicly via the site)
"""
from __future__ import print_function
from builtins import str
import os, sys, stat
from moments.path import Path
from moments.journal import Journal

here = Path('.')
print(here)
todo = Path(os.path.join(str(here), 'todo.txt'))
todo.create()
journal = Path(os.path.join(str(here), 'journal.txt'))
journal.create()

#source = open('/c/scripts/launch.sh')
f = open("launch.sh", 'w')
f.write("""#!/bin/bash

# launch.py is availble in:
# https://github.com/charlesbrandt/moments

# path to launch.py is defined in:
# ~/.bashrc
# example .bashrc is available in moments/editors/ directory

#old way
開發者ID:charlesbrandt,項目名稱:templates,代碼行數:33,代碼來源:new_context.py

示例3: make_module

# 需要導入模塊: from moments.path import Path [as 別名]
# 或者: from moments.path.Path import create [as 別名]
def make_module(module_name, short_description):

    here = Path('.')
    print(here)

    #customize:
    version = "0.1.0"
    author = "Charles Brandt"
    email = "[email protected]"

    now = Timestamp()

    #should be passed in as an argument now
    #module_name = "Probe"
    module_low = module_name.lower()
    print(module_low)

    if (here.name != module_name) and (here.name != module_low):
        print("current directory name does not equal module name:")
        print("%s != %s" % (here.name, module_name))
        exit()

    #few different good options here:
    #url = 'http://pypi.python.org/pypi/%s/' % module_name
    #url = 'http://packages.python.org/%s/' % module_name
    url = 'https://bitbucket.org/cbrandt/%s/' % module_low

    #short_description = "Objects to help process and sort collections and their contents."


    module_path = Path(os.path.join(str(here), module_low))
    if not module_path.exists():
        module_path.create()
        print("Created: %s" % module_path)

    module_init = Path(os.path.join(str(module_path), "__init__.py"))
    if not module_init.exists():
        module_init.create()
        print("Created: %s" % module_init)


    #this is the other important thing to customize:
    setup = """from setuptools import setup
#haven't gotten this to work yet:
#from distutils.core import setup

setup(
    name='%s',
    version='%s',
    author='%s',
    author_email='%s',
    packages=['%s'],
    scripts=[],
    url='%s',
    license='LICENSE.txt',
    description='%s',
    long_description=open('README.txt').read(),
    install_requires=[
    ],
)
""" % (module_name, version, author, email, module_low, url, short_description)
    f = open("setup.py", 'w')
    f.write(setup)
    f.close()

    readme = "README.txt"
    if not os.path.exists(readme):
        f = open(readme, 'w')
        f.write("""==============
{module_name}
==============

{short_description}

DOCS
---------
Complete documentation can be found in:
docs/

To generate the documentation, you will need Sphinx:
sudo easy_install sphinx

cd docs/
sphinx-build -b html . ./_build/html/

or
make html

INSTALL
----------

see docs/installation.txt

and

docs/_build/html/installation.html


CONTRIBUTORS
-----------------
#.........這裏部分代碼省略.........
開發者ID:charlesbrandt,項目名稱:templates,代碼行數:103,代碼來源:new_module.py


注:本文中的moments.path.Path.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。