PyPiCounter
v.0.2.0
이 프로젝트는 자체적으로 컴퓨터 과학 교수에게 등급을 매기도록 지원할 수있는 도구입니다. 이 도구는 명령 줄 인터페이스에서 사용자가 지정한대로 공통 컴퓨팅 구조 (예 : 기능, 클래스, 루핑 구조, 가져 오기 등)뿐만 아니라 '공통 오류가없는 클래스, Docstrings없는 기능 등'의 수를 계산하고 출력합니다.
이 프로젝트는 또한이 도구를 Allegheny College의 Gatorgrader로 가져와 새로운 Gatorgrader Checks를 만들기위한 협업 향상 역할을 할 수 있습니다. 이 프로그램은 Python 코드를 모든 형식의 세부 사항 (주석, 흰색 공간, 괄호 등)을 보관하는 CST (Concrete Syntax Tree)로 Python 코드를 구문 분석하는 LIBCST를 사용합니다. Pipy의 릴리스 도구 로서이 도구는 다른 자동화 된 등급 도구로도 가져올 수 있습니다.
poetry add pypi-counter .from pypi_count.py_counter import PyPiCount pypicounter 패키지를 가져옵니다.stored_path = PyPiCount("path_to_file") 있는 지정된 파일에서 PyPiCount 클래스를 호출하십시오. stored_path 구문 분석 파일의 결과를 저장하는 인스턴스 변수입니다. 함수는 구문 분석 파일에서 호출되어야합니다.stored_path.[function_name] 구문을 사용하여 패키지에서 함수를 실행하십시오. 예를 들어, stored_path.count_comments()최상의 결과를 얻으려면 기능이 지정된 구조의 수만 리턴하므로 인쇄 문을 추가하는 것이 좋습니다. 예를 들어,
console . print ( f"Number of comments in this file: { stored_path . count_comments () } " )생산 :
Number of comments in this file : 26사용 가능한 기능 목록은 다음과 같습니다.
count_class_definitions ( file_name )
# returns the number of class definitions
count_comments ( file_name )
# returns the number of comments
count_import_statements ( file_name )
# returns the number of import statements
count_for_loops ( file_name )
# returns the number of for loops
count_while_loops ( file_name )
# returns the number of while loops
count_function_definitions ( file_name )
# returns the number of function definitions
count_functions_without_docstrings ( file_name )
# returns the number of functions without docstrings
count_functions_with_docstrings ( file_name )
# returns the number of functions with docstrings
count_classes_with_docstrings ( file_name )
# returns the number of classes with docstrings
count_classes_without_docstrings ( file_name )
# returns the number of classes without docstrings
count_function_parameters ( file_name , function_name )
# returns the number of function parameters
# after specifying the function name
count_assignment_statements ( file_name )
# returns the number of assignment statements
count_augmented_assignment_statements ( file_name )
# returns the number of assignment statements that include
an augmented assignment operator ( + = , -= )사용자는 다음 단계를 수행 하여이 프로젝트를 시작할 수 있습니다.
pip install pypi-counter 또는 pipx install pypi-counter PIP로 패키지 설치poetry run pypicount --help 실행하십시오. 이 명령은 전달 될 수있는 모든 다른 인수를 표시합니다. 다른 인수 목록은 다음과 같습니다. Usage : pypicount [ OPTIONS ] INPUT_FILE
Main method to display the different options .
Arguments :
INPUT_FILE [ required ]
Options :
- - class - definitions [ default : False ]
- - import - statements [ default : False ]
- - comments [ default : False ]
- - function - definitions [ default : False ]
- - if - statements [ default : False ]
- - function - without - docstrings [ default : False ]
- - function - with - docstrings [ default : False ]
- - class - with - docstrings [ default : False ]
- - class - without - docstrings [ default : False ]
- - function - parameters TEXT
- - assignment - statements [ default : False ]
- - augmented - assignment - statements
[ default : False ]
- - while - loops [ default : False ]
- - for - loops [ default : False ]
- - install - completion Install completion for the current shell .
- - show - completion Show completion for the current shell , to
copy it or customize the installation .
- - help Show this message and exit .이것들은 Pypicount 가이 릴리스에서 받아 들일 수있는 다른 유형의 주장입니다.
선택한 인수를 찾으면 다음을 실행하십시오.
poetry run pypicount - - [ argument ] - - input - file path / to / file 샘플 실행 명령 :
poetry run pypicount - - class - with - docstrings - - input - file tests / input / sample_file . py샘플 출력 :
# of functions with docstrings: 1