本文整理汇总了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)
示例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
示例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
-----------------
#.........这里部分代码省略.........