-
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
The polyglot.core.Polyglot is the main class of polyglot the polyglot module.
from polyglot.core import PolyglotInitialize a polyglot instance
polyglot = Polyglot("path/to/directory", ignore="example.polyglot")Polyglot takes in to parameters, the path to the directory and the ingore file
- directory_name(required) -
stringThe path of the directory - ignore - The ignore filename
The ignore file should have a.polyglotfile extension and has a syntax similar to a.gitignorefile.-
.<extension>for file extensions -
<folder>/for folders -
<filename>for files
-
# for a specific file extension
.json
# for a specific folder
dist/
# for a specific file
dub.sdl
LICENSE
# for specific folders in the directory
~.toxand use the file with the polyglot object
poly = Polyglot(".", "example.polyglot")Getting information from the polyglot object
polyglot.show(language_detection_file="language.yml", display=True)The show method takes in two parameters, the language detection file as well as the disply option
- language_detection_file(optional) -
stringThe yaml file containing information about all the languages. By default, thelanguage_detection_fileis set toNone. and the file is downloaded from the internet. - display(optional) -
boolWhether to output the table on the console or not. The show method returns a dict containing information about the files.
The polyglot.core.tree module helps us to generate a tree of the current directory
from polyglot.core.tree import Tree
tree = Tree("path/to/directory").generate()├── colors.ts
├── gists
│ ├── gist.ts
│ └── new.ts
├── interface.ts
├── json
│ └── colors.json
├── repos.ts
└── user
└── user.tsThe polyglot.arguments.Arguments helps you parse a set of arguments and execute functions accordingly.
from polyglot.arugments import Argumentspassing in arguments
args = Arguments(arguments=[], return_value=False)
args.parse()- arguments(optional) -
listThe set of arguments. By default, the arguments in set tosys.argv[1:]. - return_value(optional) -
boolWhether to return anything or not
The polyglot.core.project.Project is used to generate folders and files.
To create a Project object
from polyglot.core.project import Project, ProjectFiles
# `.` for the current directory
project = Project("project-name", ProjectFiles(
files=["file1", "dir1/file1"],
folders=["dir2", "some-unknown-folder"]
))To generate the directories
project.create(clean=False)The create function takes in the clean parameter which determines whether to clean the project directory if it already exists. The default value is set to False
The polyglot.ext.env.Env helps to load variables defined in a .env into the process environment variables
from polyglot.ext.env import Env
env = Env()The polyglot.ext.dir outputs something similar to an ls command in linux.
from polyglot.ext.dir import directory, ls
directory("path/to/folder")
# or
ls("path/to/folder")This wiki is the same as the documentation 😄.