本文整理匯總了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