Skip to content
Snippets Groups Projects
Commit 362e8ec0 authored by tuhe's avatar tuhe
Browse files

snipper upgrade

parent f4e370ad
No related branches found
No related tags found
No related merge requests found
0.1.11 0 → 100644
Requirement already satisfied: codesnipper in c:\users\tuhe\appdata\local\programs\python\python310\lib\site-packages (0.1.11)
Requirement already satisfied: wexpect in c:\users\tuhe\appdata\local\programs\python\python310\lib\site-packages (from codesnipper) (4.0.0)
Requirement already satisfied: pybtex in c:\users\tuhe\appdata\local\programs\python\python310\lib\site-packages (from codesnipper) (0.24.0)
Requirement already satisfied: pexpect in c:\users\tuhe\appdata\local\programs\python\python310\lib\site-packages (from codesnipper) (4.8.0)
Requirement already satisfied: ptyprocess>=0.5 in c:\users\tuhe\appdata\local\programs\python\python310\lib\site-packages (from pexpect->codesnipper) (0.7.0)
Requirement already satisfied: six in c:\users\tuhe\appdata\local\programs\python\python310\lib\site-packages (from pybtex->codesnipper) (1.16.0)
Requirement already satisfied: latexcodec>=1.0.4 in c:\users\tuhe\appdata\local\programs\python\python310\lib\site-packages (from pybtex->codesnipper) (2.0.1)
Requirement already satisfied: PyYAML>=3.01 in c:\users\tuhe\appdata\local\programs\python\python310\lib\site-packages (from pybtex->codesnipper) (6.0)
Requirement already satisfied: pywin32>=220 in c:\users\tuhe\appdata\local\programs\python\python310\lib\site-packages (from wexpect->codesnipper) (304)
Requirement already satisfied: psutil>=5.0.0 in c:\users\tuhe\appdata\local\programs\python\python310\lib\site-packages (from wexpect->codesnipper) (5.9.1)
......@@ -5,10 +5,10 @@
import setuptools
import pkg_resources
with open("src/snipper/version.py", "r", encoding="utf-8") as fh:
__version__ = fh.read().split(" = ")[1].strip()[1:-1]
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
......
Metadata-Version: 2.1
Name: codesnipper
Version: 0.1.7
Version: 0.1.11
Summary: A lightweight framework for censoring student solutions files and extracting code + output
Home-page: https://lab.compute.dtu.dk/tuhe/snipper
Author: Tue Herlau
Author-email: tuhe@dtu.dk
License: MIT
Project-URL: Bug Tracker, https://lab.compute.dtu.dk/tuhe/snipper/issues
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
......@@ -405,4 +404,3 @@ raise NotImplementedError('Complete the above program')
year={2021},
}
```
......@@ -20,4 +20,5 @@ src/snipper/legacy.py
src/snipper/load_citations.py
src/snipper/snip_dir.py
src/snipper/snipper_main.py
src/snipper/test.py
src/snipper/version.py
\ No newline at end of file
import os
import io
import glob
from pybtex import plugin
from pybtex.database.input import bibtex
from warnings import warn
......@@ -8,10 +9,30 @@ from warnings import warn
def get_aux(auxfile):
# paths = get_paths()
# auxfile = os.path.join(paths['02450public'], auxfile)
auxfile = os.path.normpath(auxfile) # Unsure if this is required. But had problems finding the auxfile on git.
auxfile = auxfile.replace(os.sep, '/')
if not os.path.exists(auxfile):
# print(auxfile)
warn("Could not find bibtex file: " + auxfile + " testing for troubles")
auxdir = os.path.dirname(auxfile)
# os.path.curdir
print("The current working directory (os.getcwd()) is ", os.getcwd() )
try:
print("Trying to list files in builds dir")
for f in glob.glob("/builds/02465material/*"):
print(f)
except Exception as e:
print(e)
if not os.path.dirname(auxdir):
print("Directory for auxfile does not exist:", auxdir)
else:
print("Auxfile did not exist, but directory did. Printing the contents:")
for f in glob.glob(os.path.dirname(auxfile) + "/*"):
print(f)
warn("Could not find bibtex file: "+ auxfile)
return {}
with open(auxfile, 'r') as f:
......
import os, shutil
import os
import shutil
from snipper.snipper_main import censor_file
from pathlib import Path
import time
import fnmatch
import tempfile
from line_profiler_pycharm import profile
# from line_profiler_pycharm import profile
@profile
# @profile
def snip_dir(source_dir, # Sources
dest_dir=None, # Will write to this directory
output_dir=None, # Where snippets are going to be stored
......@@ -16,10 +17,10 @@ def snip_dir(source_dir, # Sources
cut_files=True, # censor files.
license_head=None,
censor_files=True,
verbose=True,
):
print("Snipper fixing", source_dir)
if dest_dir == None:
dest_dir = tempfile.mkdtemp()
print("[snipper]", "no destination dir was specified so using nonsense destination:", dest_dir)
......@@ -49,8 +50,8 @@ def snip_dir(source_dir, # Sources
os.makedirs(dest_dir)
out = dest_dir
hw = {'base': source_dir}
print(f"[snipper]: {hw['base']} -> {out}")
if verbose:
print(f"[snipper]: {hw['base']} -> {out}")
if os.path.exists(dest_dir):
shutil.rmtree(dest_dir)
......@@ -72,7 +73,8 @@ def snip_dir(source_dir, # Sources
if accept:
solution_list = []
kwargs = {}
print("Snipper processing", f)
if verbose:
print("Snipper processing", f)
nrem, cut = censor_file(f, run_files=run_files, run_out_dirs=output_dir, cut_files=cut_files,
# solution_list=solution_list,
base_path=dest_dir,
......@@ -80,11 +82,11 @@ def snip_dir(source_dir, # Sources
license_head=license_head,
censor_files=censor_files,
**kwargs)
if nrem > 0:
if nrem > 0 and verbose:
print(f"{nrem}> {f}")
cutouts[str(f)] = cut
n += nrem
# print("[snipper]", "removing")
for rm_file, accept in acceptable:
rm_file = os.path.abspath(rm_file)
if not accept:
......
......@@ -71,8 +71,8 @@ def censor_file(file, run_files=True, run_out_dirs=None, cut_files=True,
if censor_files:
lines = fix_f(lines, dbug)
if "pacman" in str(file):
print("sdaf")
# if "pacman" in str(file):
# print("sdaf")
lines, nB, cut = fix_b(lines)
else:
nB = 0
......
__version__ = "0.1.7"
\ No newline at end of file
__version__ = "0.1.12"
# /builds/02465material/02465public
# /builds/02465material/02465public
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment