Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
XulbuX edited this page Jan 6, 2026 · 4 revisions

Code

This class includes methods to work with code strings.


add_indent()

This method will add indent spaces at the beginning of each line.
Params:

  • code: str the string to add the indent to
  • indent: int the amount of spaces to add (default 4)

Returns: the indented string


get_tab_spaces()

This method will try to get the amount of spaces that are used for indentation.
Param: code: str the string to get the tab spaces from
Returns: the amount of spaces used for indentation


change_tab_size()

This method will change the amount of spaces used for indentation.
Params:

  • code: str the string to change the tab size of
  • new_tab_size: int the amount of spaces to use for indentation
  • remove_empty_lines: bool = False whether to remove empty lines in the process

Returns: the string with the new tab size (and no empty lines if remove_empty_lines is true)


get_func_calls()

This method will try to get all the function/method calls (JavaScript, Python, etc. style functions/methods).
Param: code: str the string to get the function/method calls from
Returns: a list of function/method calls


is_js()

This method will check if the code is likely to be JavaScript.
Params:

  • code: str the string to check
  • funcs: list[str] = ["__", "$t", "$lang"] the list of specific function names which can be in the string, that's likely JavaScript Returns: True if the code is likely to be JavaScript and False otherwise

★⠀Python Library by XulbuX ⠀★

Project Links

Testing and Formatting

Classifiers

  • Intended Audience:
    • Developers
  • License:
    • OSI Approved
    • MIT License
  • Operating Systems:
    • Full Library: OS Independent
  • Supported Python Versions:
    • Python 3.14
    • Python 3.13
    • Python 3.12
    • Python 3.11
    • Python 3.10
  • Topics:
    • Libraries
    • Python Modules
    • Software Development

The XulbuX Logo

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /