本文整理汇总了Python中txclib.config.OrderedRawConfigParser.read方法的典型用法代码示例。如果您正苦于以下问题:Python OrderedRawConfigParser.read方法的具体用法?Python OrderedRawConfigParser.read怎么用?Python OrderedRawConfigParser.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类txclib.config.OrderedRawConfigParser
的用法示例。
在下文中一共展示了OrderedRawConfigParser.read方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _read_config_file
# 需要导入模块: from txclib.config import OrderedRawConfigParser [as 别名]
# 或者: from txclib.config.OrderedRawConfigParser import read [as 别名]
def _read_config_file(self, config_file):
"""Parse the config file and return its contents."""
config = OrderedRawConfigParser()
try:
config.read(config_file)
except Exception, err:
msg = "Cannot open/parse .tx/config file: %s" % err
raise ProjectNotInit(msg)
示例2: _get_transifex_config
# 需要导入模块: from txclib.config import OrderedRawConfigParser [as 别名]
# 或者: from txclib.config.OrderedRawConfigParser import read [as 别名]
def _get_transifex_config(self, txrc_file):
"""Read the configuration from the .transifexrc file."""
txrc = OrderedRawConfigParser()
try:
txrc.read(txrc_file)
except Exception, e:
msg = "Cannot read global configuration file: %s" % e
raise ProjectNotInit(msg)
示例3: Project
# 需要导入模块: from txclib.config import OrderedRawConfigParser [as 别名]
# 或者: from txclib.config.OrderedRawConfigParser import read [as 别名]
class Project(object):
"""
Represents an association between the local and remote project instances.
"""
def __init__(self, path_to_tx=None, init=True):
"""
Initialize the Project attributes.
"""
if init:
self._init(path_to_tx)
def _init(self, path_to_tx=None):
# The path to the root of the project, where .tx lives!
self.root = path_to_tx or find_dot_tx()
logger.debug("Path to tx is %s." % self.root)
if not self.root:
MSG("Cannot find any .tx directory!")
MSG("Run 'tx init' to initialize your project first!")
raise ProjectNotInit()
# The path to the config file (.tx/config)
self.config_file = os.path.join(self.root, ".tx", "config")
logger.debug("Config file is %s" % self.config_file)
# Touch the file if it doesn't exist
if not os.path.exists(self.config_file):
MSG("Cannot find the config file (.tx/config)!")
MSG("Run 'tx init' to fix this!")
raise ProjectNotInit()
# The dictionary which holds the config parameters after deser/tion.
# Read the config in memory
self.config = OrderedRawConfigParser()
try:
self.config.read(self.config_file)
except Exception, err:
MSG("WARNING: Cannot open/parse .tx/config file", err)
MSG("Run 'tx init' to fix this!")
raise ProjectNotInit()
home = os.path.expanduser("~")
self.txrc_file = os.path.join(home, ".transifexrc")
logger.debug(".transifexrc file is at %s" % home)
if not os.path.exists(self.txrc_file):
MSG("No configuration file found.")
# Writing global configuration file
mask = os.umask(077)
open(self.txrc_file, 'w').close()
os.umask(mask)
self.txrc = OrderedRawConfigParser()
try:
self.txrc.read(self.txrc_file)
except Exception, err:
MSG("WARNING: Cannot global conf file (%s)" % err)
MSG("Run 'tx init' to fix this!")
raise ProjectNotInit()
示例4: _get_transifex_config
# 需要导入模块: from txclib.config import OrderedRawConfigParser [as 别名]
# 或者: from txclib.config.OrderedRawConfigParser import read [as 别名]
def _get_transifex_config(self, txrc_files):
"""Read the configuration from the .transifexrc files."""
txrc = OrderedRawConfigParser()
try:
txrc.read(txrc_files)
except Exception as e:
msg = "Cannot read configuration file: %s" % e
raise ProjectNotInit(msg)
self._migrate_txrc_file(txrc)
return txrc