コード例 #1
0
ファイル: package_managers.py プロジェクト: dodo325/mpm
 def get_list_repository(self) -> List[str]:
     li = not_nan_split(
         self.shell.call(
             ["grep ^ /etc/apt/sources.list /etc/apt/sources.list.d/*"]))
     li = list(map(lambda s: s[s.find(':') + 1:], li))
     li = list(filter(lambda s: not s.startswith("#"), li))
     li = list(filter(None, li))
     return li
コード例 #2
0
ファイル: test_utils.py プロジェクト: dodo325/mpm
def test_not_nan_split_1():
    a = """asdasa
    asdad
    a



    asdasd"""
    out = remove_multiple_spaces(a)
    li = not_nan_split(out)
    assert len(li) == 4
コード例 #3
0
ファイル: packages.py プロジェクト: dodo325/mpm
 def show(self) -> dict:
     try:
         out = self.shell.call(["npm", "view", self.package_name, "--json"])
     except ProcessExecutionError as e:
         self.console.print_exception()
     # out = out[out.find("{\n"):]
     out_2 = ""
     for line in not_nan_split(out):
         if not line.startswith("npm"):
             out_2 += line + "\n"
     out = out_2
     data = json.loads(out)
     data["version"] = data["versions"][-1]
     data.pop("name")
     return data
コード例 #4
0
ファイル: package_managers.py プロジェクト: dodo325/mpm
 def search(self, package_name: str) -> dict:
     try:
         out = self.shell.call(["apt-cache", "search", package_name])
     except Exception as e:
         self.logger.error(f"Nothing found for {package_name}!")
         return {}
     out = self._remove_warnings(out)
     if out == "":
         return {}
     data = {}
     for line in not_nan_split(out):
         delimiter = " - "
         n = line.find(delimiter)
         name = line[:n]
         description = line[n + len(delimiter):]
         data[name] = {"description": description}
     return data
コード例 #5
0
ファイル: package_managers.py プロジェクト: dodo325/mpm
    def search(self, package_name: str) -> dict:
        """
        RAW output:
        numpy (1.18.4)                            - NumPy is the fundamental package
                                                    for array computing with Python.
          INSTALLED: 1.18.1
          LATEST:    1.18.4
        numpy-cloud (0.0.5)                       - Numpy in the cloud
        numpy-ext (0.9.2)                         - numpy extension
        numpy-alignments (0.0.2)                  - Numpy Alignments
        numpy-utils (0.1.6)                       - NumPy utilities.
        """
        try:
            out = self.shell.call(["pip", "search", package_name])
        except Exception as e:
            self.logger.error(
                f"Nothing found for {package_name}!")  # , exc_info=True)
            return {}
        li = not_nan_split(out)
        data = {}
        name = ''
        for line in li:
            try:
                if line.startswith(" "):
                    key, val = line.split(":")
                    key, val = key.strip(), val.strip()
                    key, val = key.lower(), val.lower()
                    data[name][key] = val
                    continue

                version = re.search(r"\((.*?)\)", line).group(1)
                name = line[:line.find("(")].strip()
                description = line[line.rfind("-") + 1:].strip()
                data[name] = {"version": version, "description": description}
            except (AttributeError, ValueError):
                self.logger.debug("SearchParseError", exc_info=True)
                continue
        return data