1 | import { SoftwarePackage } from '@stencila/schema';
|
2 | import Parser from './Parser';
|
3 | export declare enum RequirementType {
|
4 | Named = 0,
|
5 | URL = 1
|
6 | }
|
7 | interface PythonRequirement {
|
8 | /**
|
9 | * Type of requirement specified (name or URL)
|
10 | */
|
11 | type: RequirementType;
|
12 | /**
|
13 | * Name or URL value of the requirement
|
14 | */
|
15 | value: string;
|
16 | /**
|
17 | * Version of the requirement
|
18 | */
|
19 | version?: string | null;
|
20 | }
|
21 | /**
|
22 | * Parser to be used on a directory with Python source code and (optionally) a `requirements.txt` file.
|
23 | * If no `requirements.txt` file exists then the Parser will attempt to read requirements from the Python source code.
|
24 | */
|
25 | export default class PythonParser extends Parser {
|
26 | parse(): Promise<SoftwarePackage | null>;
|
27 | /**
|
28 | * Convert a `PythonRequirement` into a `SoftwarePackage` by augmenting with metadata from PyPI
|
29 | */
|
30 | private createPackage;
|
31 | /**
|
32 | * Parse a `requirements.txt` file at `path` and return a list of `PythonRequirement`s
|
33 | */
|
34 | parseRequirementsFile(path: string): Promise<Array<PythonRequirement>>;
|
35 | /**
|
36 | * Parse Python source files are find any non-system imports, return this as an array of `PythonRequirement`s.
|
37 | */
|
38 | generateRequirementsFromSource(): Array<PythonRequirement>;
|
39 | /**
|
40 | * Parse Python source files are find all imports (including system imports).
|
41 | */
|
42 | findImports(): Array<string>;
|
43 | /**
|
44 | * Parse Python a single Python source file for imports.
|
45 | */
|
46 | readImportsInFile(path: string): Array<string>;
|
47 | }
|
48 | export {};
|