Skip to content

PythonParser

reference
1 min readUpdated

Kind: Class

Source: atloria-monorepo/libs/parser-core/src/parsers/backend/python.parser.ts

Python Project Parser implementation

Implements: IParser

Methods

MethodSignatureReturns
initializeinitialize(_config: ParserConfig)Promise<void>
canParsecanParse(filePath: string)boolean
parseFileparseFile(filePath: string, content: string)Promise<ParseResult>
parseFilesparseFiles(files: ParseFileInput[])Promise<ParseResult[]>
destroydestroy()Promise<void>

Properties

PropertyType
nameany
versionany
supportedPatternsany

Where it refuses work

  • PythonParser stops the work with an early return when /\.python-version$/.test(filePath) || /runtime\.txt$/.test(filePath).
  • PythonParser stops the work with an early return when !match.
  • PythonParser stops the work with an early return when versionSpec === '*' || versionSpec === ''.
  • PythonParser stops the work with an early return when /^[0-9.]+$/.test(versionSpec).
  • PythonParser stops the work with an early return when /^[><=!]/.test(versionSpec).

When something fails

  • PythonParser handles failure in 3 places: it turns it into a return value in all 3.

Was this page helpful?

Download as PDF