Este proyecto es una herramienta que, por sí sola, brindará asistencia a los profesores de informática para ayudar a calificar las tareas. Esta herramienta contará y emitirá el número de 'errores comunes' (por ejemplo, clases sin monedas, funciones sin documentos, etc.), así como el número de estructuras informáticas comunes (p. Ej.
Este proyecto también puede servir como una mejora colaborativa para importar esta herramienta al propio Gatorgrader de Allegheny College para crear nuevos cheques de GatorGrader. El programa utiliza LibCST, que analiza el código Python como un CST (árbol de sintaxis concreto) que mantiene todos los detalles de formato (comentarios, espacios blancos, paréntesis, etc.). Como herramienta lanzada en Pipy, esta herramienta también se puede importar a cualquier otra herramienta de calificación automatizada.
poetry add pypi-counter en su terminal.from pypi_count.py_counter import PyPiCount .PyPiCount en el archivo especificado con la siguiente sintaxis: stored_path = PyPiCount("path_to_file") A lo largo de este ejemplo, stored_path es una variable de instancia que almacena el resultado del archivo analizado. Las funciones deben llamarse en un archivo analizado.stored_path.[function_name] . Por ejemplo, stored_path.count_comments()Para obtener los mejores resultados, recomendamos agregar una declaración de impresión, ya que las funciones solo devolverán el número de la construcción especificada. Por ejemplo,
console . print ( f"Number of comments in this file: { stored_path . count_comments () } " )Producirá:
Number of comments in this file : 26La lista de funciones disponibles son:
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 ( + = , -= )Los usuarios pueden comenzar con este proyecto siguiendo los siguientes pasos:
pip install pypi-counter o pipx install pypi-counterpoetry run pypicount --help . Este comando muestra todos los diferentes argumentos que se pueden aprobar. La lista de los diferentes argumentos se enumeran a continuación: 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 .Estos son los diferentes tipos de argumentos que Pypicount aceptará en esta versión.
Una vez que encuentre sus argumentos elegidos, ejecute lo siguiente:
poetry run pypicount - - [ argument ] - - input - file path / to / file Comando de ejecución de muestra:
poetry run pypicount - - class - with - docstrings - - input - file tests / input / sample_file . pySalida de muestra:
# of functions with docstrings: 1