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


Python Util.read_file方法代碼示例

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


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

示例1: launch

# 需要導入模塊: from ensime_shared.util import Util [as 別名]
# 或者: from ensime_shared.util.Util import read_file [as 別名]
    def launch(self):
        if not self.isinstalled():
            raise LaunchError('Bootstrap classpath file does not exist at {}'
                              .format(self.classpath_file))

        classpath = Util.read_file(self.classpath_file) + ':' + self.toolsjar
        return self._start_process(classpath)
開發者ID:ensime,項目名稱:ensime-vim,代碼行數:9,代碼來源:launcher.py

示例2: parse_conf

# 需要導入模塊: from ensime_shared.util import Util [as 別名]
# 或者: from ensime_shared.util.Util import read_file [as 別名]
    def parse_conf(self, path):
        def paired(iterable):
            """s -> (s0, s1), (s2, s3), (s4, s5), ..."""
            cursor = iter(iterable)
            return zip(cursor, cursor)

        def unwrap_if_sexp_symbol(datum):
            """
            Convert Symbol(':key') to ':key' (Symbol isn't hashable for dict keys).
            """
            return datum.value() if isinstance(datum, sexpdata.Symbol) else datum

        def sexp2dict(sexps):
            """
            Transforms a nested list structure from sexpdata to dict.

            NOTE: This probably isn't general for all S-expression shapes parsed by
            sexpdata, focused only on .ensime thus far.
            """
            newdict = {}

            # Turn flat list into associative pairs
            for key, value in paired(sexps):
                key = str(unwrap_if_sexp_symbol(key)).lstrip(':')

                # Recursively transform nested lists
                if isinstance(value, list) and value and isinstance(value[0], list):
                    newdict[key] = [sexp2dict(value[0])]
                else:
                    newdict[key] = value

            return newdict

        conf = sexpdata.loads(Util.read_file(path))
        return sexp2dict(conf)
開發者ID:ChrisCoffey,項目名稱:ensime-vim,代碼行數:37,代碼來源:launcher.py

示例3: load_classpath

# 需要導入模塊: from ensime_shared.util import Util [as 別名]
# 或者: from ensime_shared.util.Util import read_file [as 別名]
 def load_classpath(self, scala_version, java_home):
     project_dir = self.classpath_project_dir(scala_version)
     classpath_file = os.path.join(project_dir, "classpath")
     if not os.path.exists(classpath_file):
         if not self.generate_classpath(scala_version, classpath_file):
             return None
     return "{}:{}/lib/tools.jar".format(
         Util.read_file(classpath_file), java_home)
開發者ID:hkupty,項目名稱:ensime-vim,代碼行數:10,代碼來源:launcher.py

示例4: parse_conf

# 需要導入模塊: from ensime_shared.util import Util [as 別名]
# 或者: from ensime_shared.util.Util import read_file [as 別名]
 def parse_conf(self, path):
     conf = Util.read_file(path).replace("\n", "").replace(
             "(", " ").replace(")", " ").replace('"', "").split(" :")
     pattern = re.compile("([^ ]*) *(.*)$")
     conf = [(m[0], m[1])for m in [pattern.match(x).groups() for x in conf]]
     result = {}
     for item in conf:
         result[item[0]] = item[1]
     return result
開發者ID:guersam,項目名稱:ensime-vim,代碼行數:11,代碼來源:launcher.py

示例5: load_classpath

# 需要導入模塊: from ensime_shared.util import Util [as 別名]
# 或者: from ensime_shared.util.Util import read_file [as 別名]
    def load_classpath(self, scala_version, java_home):
        project_dir = self.classpath_project_dir(scala_version)
        classpath_file = os.path.join(project_dir, "classpath")
        if not os.path.exists(classpath_file):
            if not self.generate_classpath(scala_version, classpath_file):
                return None
        classpath = "{}:{}/lib/tools.jar".format(
            Util.read_file(classpath_file), java_home)

        for x in os.listdir(self.base_dir):
            if fnmatch.fnmatch(x, "ensime_" + scala_version[:4] + "*-assembly.jar"):
                classpath = os.path.join(self.base_dir, x) + ":" + classpath

        return classpath
開發者ID:ChrisCoffey,項目名稱:ensime-vim,代碼行數:16,代碼來源:launcher.py

示例6: load_classpath

# 需要導入模塊: from ensime_shared.util import Util [as 別名]
# 或者: from ensime_shared.util.Util import read_file [as 別名]
    def load_classpath(self):
        if not os.path.exists(self.classpath_file):
            if not self.generate_classpath():
                return None

        classpath = "{}:{}/lib/tools.jar".format(Util.read_file(self.classpath_file), self.config["java-home"])

        # Allow override with a local development server jar, see:
        # http://ensime.github.io/contributing/#manual-qa-testing
        for x in os.listdir(self.base_dir):
            if fnmatch.fnmatch(x, "ensime_" + self.scala_minor + "*-assembly.jar"):
                classpath = os.path.join(self.base_dir, x) + ":" + classpath

        return classpath
開發者ID:ktonga,項目名稱:ensime-vim,代碼行數:16,代碼來源:launcher.py

示例7: parse

# 需要導入模塊: from ensime_shared.util import Util [as 別名]
# 或者: from ensime_shared.util.Util import read_file [as 別名]
    def parse(path):
        """Parse an ``.ensime`` config file from S-expressions.

        Args:
            path (str): Path of an ``.ensime`` file to parse.

        Returns:
            dict: Configuration values with string keys.
        """

        def paired(iterable):
            """s -> (s0, s1), (s2, s3), (s4, s5), ..."""
            cursor = iter(iterable)
            return zip(cursor, cursor)

        def unwrap_if_sexp_symbol(datum):
            """Convert Symbol(':key') to ':key' (Symbol isn't hashable for dict keys).
            """
            return datum.value() if isinstance(datum, sexpdata.Symbol) else datum

        def sexp2dict(sexps):
            """Transforms a nested list structure from sexpdata to dict."""
            newdict = {}

            # Turn flat list into associative pairs
            for key, value in paired(sexps):
                key = str(unwrap_if_sexp_symbol(key)).lstrip(':')

                # Recursively transform nested lists
                if isinstance(value, list) and value:
                    if isinstance(value[0], list):
                        newdict[key] = [sexp2dict(val) for val in value]
                    elif isinstance(value[0], sexpdata.Symbol):
                        newdict[key] = sexp2dict(value)
                    else:
                        newdict[key] = value
                else:
                    newdict[key] = value

            return newdict

        conf = sexpdata.loads(Util.read_file(path))
        return sexp2dict(conf)
開發者ID:ensime,項目名稱:ensime-vim,代碼行數:45,代碼來源:config.py

示例8: http_port

# 需要導入模塊: from ensime_shared.util import Util [as 別名]
# 或者: from ensime_shared.util.Util import read_file [as 別名]
 def http_port(self):
     return int(Util.read_file(os.path.join(self.cache_dir, "http")))
開發者ID:guersam,項目名稱:ensime-vim,代碼行數:4,代碼來源:launcher.py


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