Skip to content

xx_code

XulbuX edited this page Jun 17, 2025 · 10 revisions

Code

This class includes methods, used to work with strings, which include code.


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.13
    • Python 3.12
    • Python 3.11
    • Python 3.10
  • Topics:
    • Libraries
    • Python Modules
    • Software Development

The XulbuX Logo
Clone this wiki locally