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


Python OrderedRawConfigParser.read方法代碼示例

本文整理匯總了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)
開發者ID:sayanchowdhury,項目名稱:transifex-client,代碼行數:10,代碼來源:project.py

示例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)
開發者ID:sayanchowdhury,項目名稱:transifex-client,代碼行數:10,代碼來源:project.py

示例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()
開發者ID:tbarbugli,項目名稱:transifex-client,代碼行數:60,代碼來源:project.py

示例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
開發者ID:akx,項目名稱:transifex-client,代碼行數:12,代碼來源:project.py


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