@NotNull
  private static List<RepoPackage> getPackagesFromAdditionalRepository(@NotNull String url)
      throws IOException {
    final List<RepoPackage> result = new ArrayList<>();
    final boolean simpleIndex = url.endsWith("simple/");
    final List<String> packagesList = parsePyPIListFromWeb(url, simpleIndex);

    for (String pyPackage : packagesList) {
      if (simpleIndex) {
        final Pair<String, String> nameVersion =
            splitNameVersion(StringUtil.trimTrailing(pyPackage, '/'));
        result.add(new RepoPackage(nameVersion.getFirst(), url, nameVersion.getSecond()));
      } else {
        try {
          final Pattern repositoryPattern = Pattern.compile(url + "([^/]*)/([^/]*)$");
          final Matcher matcher = repositoryPattern.matcher(URLDecoder.decode(pyPackage, "UTF-8"));
          if (matcher.find()) {
            final String packageName = matcher.group(1);
            final String packageVersion = matcher.group(2);
            if (!packageName.contains(" ")) {
              result.add(new RepoPackage(packageName, url, packageVersion));
            }
          }
        } catch (UnsupportedEncodingException e) {
          LOG.warn(e.getMessage());
        }
      }
    }
    return result;
  }
    @NotNull
    @Override
    public PsiReference[] getReferencesByElement(
        @NotNull final PsiElement element, @NotNull final ProcessingContext context) {
      if (!(element instanceof YAMLKeyValue) || !isPathPackageDefinition((YAMLKeyValue) element)) {
        return PsiReference.EMPTY_ARRAY;
      }

      final PsiElement value = ((YAMLKeyValue) element).getValue();
      if (value == null) {
        return PsiReference.EMPTY_ARRAY;
      }

      final String text =
          StringUtil.trimTrailing(FileUtil.toSystemIndependentName(value.getText()));
      final boolean quoted = StringUtil.isQuotedString(text);
      final int startInElement = value.getStartOffsetInParent() + (quoted ? 1 : 0);

      final FileReferenceSet fileReferenceSet =
          new FileReferenceSet(
              StringUtil.unquoteString(text),
              element,
              startInElement,
              this,
              SystemInfo.isFileSystemCaseSensitive,
              false) {
            @NotNull
            @Override
            public Collection<PsiFileSystemItem> computeDefaultContexts() {
              if (isAbsolutePathReference()) {
                final VirtualFile[] roots = ManagingFS.getInstance().getLocalRoots();
                final Collection<PsiFileSystemItem> result = new SmartList<PsiFileSystemItem>();
                for (VirtualFile root : roots) {
                  ContainerUtil.addIfNotNull(result, element.getManager().findDirectory(root));
                }
                return result;
              }

              return super.computeDefaultContexts();
            }

            @Override
            public boolean isAbsolutePathReference() {
              final String path = getPathString();
              return SystemInfo.isWindows
                  ? path.length() >= 3
                      && Character.isLetter(path.charAt(0))
                      && ':' == path.charAt(1)
                      && '/' == path.charAt(2)
                  : path.startsWith("/");
            }

            @Override
            protected Condition<PsiFileSystemItem> getReferenceCompletionFilter() {
              return DIRECTORY_FILTER;
            }
          };

      return fileReferenceSet.getAllReferences();
    }
  @Nullable
  private static String getVersionByJarFileName(@NotNull String fileName) {
    Matcher fileNameMatcher = JAR_FILE_NAME_PATTERN.matcher(fileName);
    if (!fileNameMatcher.matches()) return null;

    return StringUtil.trimTrailing(fileNameMatcher.group(1), '.');
  }
 private void processOneLine(String line) {
   int indentSize = IndentHelperImpl.getIndent(getProject(), PythonFileType.INSTANCE, line, false);
   line = StringUtil.trimTrailing(line);
   if (StringUtil.isEmptyOrSpaces(line)) {
     doProcessLine("\n");
   } else if (indentSize == 0
       && indentSize < myCurrentIndentSize
       && !PyConsoleIndentUtil.shouldIndent(line)
       && !myConsoleCommunication.isWaitingForInput()) {
     doProcessLine("\n");
     doProcessLine(line);
   } else {
     doProcessLine(line);
   }
 }