submissionsync 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- submissionsync-0.1.0/LICENSE +21 -0
- submissionsync-0.1.0/PKG-INFO +125 -0
- submissionsync-0.1.0/README.md +103 -0
- submissionsync-0.1.0/pyproject.toml +28 -0
- submissionsync-0.1.0/setup.cfg +4 -0
- submissionsync-0.1.0/setup.py +33 -0
- submissionsync-0.1.0/submissionsync/__init__.py +14 -0
- submissionsync-0.1.0/submissionsync/__main__.py +4 -0
- submissionsync-0.1.0/submissionsync/cli.py +83 -0
- submissionsync-0.1.0/submissionsync/core.py +191 -0
- submissionsync-0.1.0/submissionsync/shortcuts.py +14 -0
- submissionsync-0.1.0/submissionsync.egg-info/PKG-INFO +125 -0
- submissionsync-0.1.0/submissionsync.egg-info/SOURCES.txt +15 -0
- submissionsync-0.1.0/submissionsync.egg-info/dependency_links.txt +1 -0
- submissionsync-0.1.0/submissionsync.egg-info/entry_points.txt +2 -0
- submissionsync-0.1.0/submissionsync.egg-info/requires.txt +5 -0
- submissionsync-0.1.0/submissionsync.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 UTC Sheffield
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: submissionsync
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Create shortcuts to latest submitted MS teams assignment versions
|
|
5
|
+
Home-page: https://github.com/UTCSheffield/ms-teams-latest-submitted-version
|
|
6
|
+
Author: Your Name
|
|
7
|
+
Author-email: Martyn Eggleton <meggleton@utcsheffield.org.uk>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/UTCSheffield/ms-teams-latest-submitted-version
|
|
10
|
+
Keywords: submissions,shortcuts,assignments,windows
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: seedir>=0.4.0
|
|
15
|
+
Requires-Dist: pywin32>=302
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
18
|
+
Dynamic: author
|
|
19
|
+
Dynamic: home-page
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
|
|
23
|
+
# submissionsync
|
|
24
|
+
|
|
25
|
+
Create shortcuts to the latest submitted assignment versions from a hierarchical student work directory structure.
|
|
26
|
+
|
|
27
|
+
## Overview
|
|
28
|
+
|
|
29
|
+
`submissionsync` automates the organization of student submissions by creating shortcuts to only the latest version of each assignment. Perfect for managing large volumes of student work organized in the nested directories produced by "MS Teams Assignments".
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
- 🔗 Automatic shortcut creation to latest submission versions
|
|
34
|
+
- 📁 Intelligent filtering of Student Work directories
|
|
35
|
+
- ⚡ Modification time caching for performance
|
|
36
|
+
- 🔄 Force rebuild option for rechecking all submissions
|
|
37
|
+
- 🐛 Debug mode for troubleshooting
|
|
38
|
+
- 📊 Optional directory tree visualization
|
|
39
|
+
- 🖥️ Cross-platform Python module (shortcuts on Windows)
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install submissionsync
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Quick Start
|
|
48
|
+
|
|
49
|
+
### Using Defaults
|
|
50
|
+
|
|
51
|
+
Run with default paths:
|
|
52
|
+
```bash
|
|
53
|
+
submissionsync
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
This uses:
|
|
57
|
+
- **Source**: `~/UTC Sheffield`
|
|
58
|
+
- **Output**: `P:\Documents\Student Work - Latest Submissions`
|
|
59
|
+
|
|
60
|
+
### Custom Directories
|
|
61
|
+
|
|
62
|
+
Specify custom source and output paths:
|
|
63
|
+
```bash
|
|
64
|
+
submissionsync /path/to/student/work /path/to/output
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Usage
|
|
68
|
+
|
|
69
|
+
### Command Line Interface
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
submissionsync [SOURCE] [OUTPUT] [OPTIONS]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Arguments:**
|
|
76
|
+
- `SOURCE`: Source directory containing student work (optional, default: `~/UTC Sheffield`)
|
|
77
|
+
- `OUTPUT`: Output directory for shortcuts (optional, default: `P:\Documents\Student Work - Latest Submissions`)
|
|
78
|
+
|
|
79
|
+
**Options:**
|
|
80
|
+
```bash
|
|
81
|
+
--debug Show detailed processing information
|
|
82
|
+
--show-tree Display directory tree before processing
|
|
83
|
+
--force Force recreation of all shortcuts (ignore cache)
|
|
84
|
+
--version Show version and exit
|
|
85
|
+
--help Show help message and exit
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Examples
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Debug mode with verbose output
|
|
92
|
+
submissionsync --debug
|
|
93
|
+
|
|
94
|
+
# Force rebuild of all shortcuts
|
|
95
|
+
submissionsync --force
|
|
96
|
+
|
|
97
|
+
# Show directory tree and process
|
|
98
|
+
submissionsync --show-tree
|
|
99
|
+
|
|
100
|
+
# Custom paths with options
|
|
101
|
+
submissionsync /source/path /output/path --debug --force
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Module Usage
|
|
105
|
+
|
|
106
|
+
Use `submissionsync` as a Python library:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
python -m submissionsync
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Available Functions
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from submissionsync import (
|
|
116
|
+
mask, # Filter mask for relevant directories
|
|
117
|
+
get_latest_mtime, # Get latest modification time in path
|
|
118
|
+
iter_latest_versions, # Iterate over latest version folders
|
|
119
|
+
create_symlink_structure # Main function to create shortcuts
|
|
120
|
+
)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Directory Structure
|
|
124
|
+
|
|
125
|
+
The tool expects a structure like:
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# submissionsync
|
|
2
|
+
|
|
3
|
+
Create shortcuts to the latest submitted assignment versions from a hierarchical student work directory structure.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`submissionsync` automates the organization of student submissions by creating shortcuts to only the latest version of each assignment. Perfect for managing large volumes of student work organized in the nested directories produced by "MS Teams Assignments".
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- 🔗 Automatic shortcut creation to latest submission versions
|
|
12
|
+
- 📁 Intelligent filtering of Student Work directories
|
|
13
|
+
- ⚡ Modification time caching for performance
|
|
14
|
+
- 🔄 Force rebuild option for rechecking all submissions
|
|
15
|
+
- 🐛 Debug mode for troubleshooting
|
|
16
|
+
- 📊 Optional directory tree visualization
|
|
17
|
+
- 🖥️ Cross-platform Python module (shortcuts on Windows)
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install submissionsync
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
### Using Defaults
|
|
28
|
+
|
|
29
|
+
Run with default paths:
|
|
30
|
+
```bash
|
|
31
|
+
submissionsync
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
This uses:
|
|
35
|
+
- **Source**: `~/UTC Sheffield`
|
|
36
|
+
- **Output**: `P:\Documents\Student Work - Latest Submissions`
|
|
37
|
+
|
|
38
|
+
### Custom Directories
|
|
39
|
+
|
|
40
|
+
Specify custom source and output paths:
|
|
41
|
+
```bash
|
|
42
|
+
submissionsync /path/to/student/work /path/to/output
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
### Command Line Interface
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
submissionsync [SOURCE] [OUTPUT] [OPTIONS]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Arguments:**
|
|
54
|
+
- `SOURCE`: Source directory containing student work (optional, default: `~/UTC Sheffield`)
|
|
55
|
+
- `OUTPUT`: Output directory for shortcuts (optional, default: `P:\Documents\Student Work - Latest Submissions`)
|
|
56
|
+
|
|
57
|
+
**Options:**
|
|
58
|
+
```bash
|
|
59
|
+
--debug Show detailed processing information
|
|
60
|
+
--show-tree Display directory tree before processing
|
|
61
|
+
--force Force recreation of all shortcuts (ignore cache)
|
|
62
|
+
--version Show version and exit
|
|
63
|
+
--help Show help message and exit
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Examples
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Debug mode with verbose output
|
|
70
|
+
submissionsync --debug
|
|
71
|
+
|
|
72
|
+
# Force rebuild of all shortcuts
|
|
73
|
+
submissionsync --force
|
|
74
|
+
|
|
75
|
+
# Show directory tree and process
|
|
76
|
+
submissionsync --show-tree
|
|
77
|
+
|
|
78
|
+
# Custom paths with options
|
|
79
|
+
submissionsync /source/path /output/path --debug --force
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Module Usage
|
|
83
|
+
|
|
84
|
+
Use `submissionsync` as a Python library:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
python -m submissionsync
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Available Functions
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from submissionsync import (
|
|
94
|
+
mask, # Filter mask for relevant directories
|
|
95
|
+
get_latest_mtime, # Get latest modification time in path
|
|
96
|
+
iter_latest_versions, # Iterate over latest version folders
|
|
97
|
+
create_symlink_structure # Main function to create shortcuts
|
|
98
|
+
)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Directory Structure
|
|
102
|
+
|
|
103
|
+
The tool expects a structure like:
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=45", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "submissionsync"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Create shortcuts to latest submitted MS teams assignment versions"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Martyn Eggleton", email = "meggleton@utcsheffield.org.uk"}
|
|
14
|
+
]
|
|
15
|
+
keywords = ["submissions", "shortcuts", "assignments", "windows"]
|
|
16
|
+
dependencies = [
|
|
17
|
+
"seedir>=0.4.0",
|
|
18
|
+
"pywin32>=302"
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.optional-dependencies]
|
|
22
|
+
dev = ["pytest>=6.0"]
|
|
23
|
+
|
|
24
|
+
[project.scripts]
|
|
25
|
+
submissionsync = "submissionsync.cli:main"
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Homepage = "https://github.com/UTCSheffield/ms-teams-latest-submitted-version"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name='submissionsync',
|
|
5
|
+
version='0.1.0',
|
|
6
|
+
description='Create shortcuts to latest submitted assignment versions',
|
|
7
|
+
author='Your Name',
|
|
8
|
+
author_email='your.email@example.com',
|
|
9
|
+
url='https://github.com/UTCSheffield/ms-teams-latest-submitted-version',
|
|
10
|
+
packages=find_packages(),
|
|
11
|
+
python_requires='>=3.8',
|
|
12
|
+
install_requires=[
|
|
13
|
+
'seedir>=0.4.0',
|
|
14
|
+
'pywin32>=305; sys_platform == "win32"',
|
|
15
|
+
],
|
|
16
|
+
entry_points={
|
|
17
|
+
'console_scripts': [
|
|
18
|
+
'submissionsync=submissionsync.cli:main',
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
classifiers=[
|
|
22
|
+
'Development Status :: 3 - Alpha',
|
|
23
|
+
'Intended Audience :: Developers',
|
|
24
|
+
'License :: OSI Approved :: MIT License',
|
|
25
|
+
'Programming Language :: Python :: 3',
|
|
26
|
+
'Programming Language :: Python :: 3.8',
|
|
27
|
+
'Programming Language :: Python :: 3.9',
|
|
28
|
+
'Programming Language :: Python :: 3.10',
|
|
29
|
+
'Programming Language :: Python :: 3.11',
|
|
30
|
+
'Programming Language :: Python :: 3.12',
|
|
31
|
+
'Operating System :: Microsoft :: Windows',
|
|
32
|
+
],
|
|
33
|
+
)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import sys
|
|
3
|
+
import time
|
|
4
|
+
from pathlib import Path, WindowsPath
|
|
5
|
+
from .core import create_symlink_structure
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def main():
|
|
9
|
+
parser = argparse.ArgumentParser(
|
|
10
|
+
description='Create shortcuts to latest submitted assignment versions',
|
|
11
|
+
prog='submissionsync'
|
|
12
|
+
)
|
|
13
|
+
parser.add_argument(
|
|
14
|
+
'source',
|
|
15
|
+
nargs='?',
|
|
16
|
+
help='Source directory containing student work (default: ~/UTC Sheffield)'
|
|
17
|
+
)
|
|
18
|
+
parser.add_argument(
|
|
19
|
+
'output',
|
|
20
|
+
nargs='?',
|
|
21
|
+
help='Output directory for shortcuts (default: P:/Documents/Student Work - Latest Submissions)'
|
|
22
|
+
)
|
|
23
|
+
parser.add_argument(
|
|
24
|
+
'--debug',
|
|
25
|
+
action='store_true',
|
|
26
|
+
help='Enable debug output'
|
|
27
|
+
)
|
|
28
|
+
parser.add_argument(
|
|
29
|
+
'--show-tree',
|
|
30
|
+
action='store_true',
|
|
31
|
+
help='Display directory tree before processing'
|
|
32
|
+
)
|
|
33
|
+
parser.add_argument(
|
|
34
|
+
'--force',
|
|
35
|
+
action='store_true',
|
|
36
|
+
help='Force recreation of all shortcuts'
|
|
37
|
+
)
|
|
38
|
+
parser.add_argument(
|
|
39
|
+
'--verbose',
|
|
40
|
+
action='store_true',
|
|
41
|
+
help='Print verbose debug information'
|
|
42
|
+
)
|
|
43
|
+
parser.add_argument(
|
|
44
|
+
'--version',
|
|
45
|
+
action='version',
|
|
46
|
+
version='%(prog)s 0.1.0'
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
args = parser.parse_args()
|
|
50
|
+
|
|
51
|
+
# Set defaults
|
|
52
|
+
source_path = Path(args.source) if args.source else Path.home() / "UTC Sheffield"
|
|
53
|
+
output_path = Path(args.output) if args.output else WindowsPath("P:\\Documents") / "Student Work - Latest Submissions"
|
|
54
|
+
|
|
55
|
+
print("\n" + "=" * 50)
|
|
56
|
+
print("Creating shortcuts structure...")
|
|
57
|
+
print("=" * 50 + "\n")
|
|
58
|
+
|
|
59
|
+
if args.verbose:
|
|
60
|
+
print("Verbose mode enabled: printing debug information.\n")
|
|
61
|
+
|
|
62
|
+
start_time = time.perf_counter()
|
|
63
|
+
try:
|
|
64
|
+
create_symlink_structure(
|
|
65
|
+
source_path,
|
|
66
|
+
output_path,
|
|
67
|
+
debug=args.debug or args.verbose,
|
|
68
|
+
show_tree=args.show_tree,
|
|
69
|
+
force=args.force
|
|
70
|
+
)
|
|
71
|
+
elapsed = time.perf_counter() - start_time
|
|
72
|
+
|
|
73
|
+
print(f"\nShortcuts structure created at: {output_path}")
|
|
74
|
+
print("\nYou can now browse the organized structure at:")
|
|
75
|
+
print(f" {output_path}")
|
|
76
|
+
print(f"\nCompleted in {elapsed:.2f} seconds.")
|
|
77
|
+
except Exception as e:
|
|
78
|
+
print(f"\nError: {e}", file=sys.stderr)
|
|
79
|
+
sys.exit(1)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
if __name__ == '__main__':
|
|
83
|
+
main()
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
import seedir as sd
|
|
3
|
+
import win32com.client
|
|
4
|
+
from .shortcuts import create_shortcut
|
|
5
|
+
|
|
6
|
+
shell = None
|
|
7
|
+
try:
|
|
8
|
+
shell = win32com.client.Dispatch("WScript.Shell")
|
|
9
|
+
except Exception:
|
|
10
|
+
print(" ✗ pywin32 not installed; shortcuts will not be created")
|
|
11
|
+
exit()
|
|
12
|
+
|
|
13
|
+
def mask(x):
|
|
14
|
+
if x.is_dir() and ("Student Work" in str(x)):
|
|
15
|
+
if "Enrichment" in str(x) or "Club" in str(x):
|
|
16
|
+
return False
|
|
17
|
+
if len(x.parts) > 5:
|
|
18
|
+
if "Submitted files" in str(x):
|
|
19
|
+
if len(x.parts) > 8:
|
|
20
|
+
if "Version" in str(x):
|
|
21
|
+
version_num = int(x.parts[-1].split(" ")[1]) + 1
|
|
22
|
+
next_folder = (x.parents[0] /
|
|
23
|
+
("Version " + str(version_num)))
|
|
24
|
+
return not next_folder.exists()
|
|
25
|
+
else:
|
|
26
|
+
return False
|
|
27
|
+
else:
|
|
28
|
+
return True
|
|
29
|
+
return False
|
|
30
|
+
else:
|
|
31
|
+
return True
|
|
32
|
+
return False
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_latest_mtime(path: Path) -> float:
|
|
36
|
+
"""Return the most recent modification time under a path."""
|
|
37
|
+
if not path.exists():
|
|
38
|
+
return 0.0
|
|
39
|
+
latest = path.stat().st_mtime
|
|
40
|
+
for p in path.rglob("*"):
|
|
41
|
+
try:
|
|
42
|
+
latest = max(latest, p.stat().st_mtime)
|
|
43
|
+
except FileNotFoundError:
|
|
44
|
+
continue
|
|
45
|
+
return latest
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def iter_latest_versions(base_path, cutoff_mtime=None, dbg=lambda *args, **kwargs: None):
|
|
49
|
+
"""Yield only latest version folders (optionally filtered by mtime)."""
|
|
50
|
+
for folder in base_path.rglob("Version *"):
|
|
51
|
+
if cutoff_mtime is not None:
|
|
52
|
+
try:
|
|
53
|
+
if folder.stat().st_mtime <= cutoff_mtime:
|
|
54
|
+
dbg(f" - Skipping (not newer than cutoff): {folder}")
|
|
55
|
+
continue
|
|
56
|
+
except FileNotFoundError:
|
|
57
|
+
continue
|
|
58
|
+
if mask(folder):
|
|
59
|
+
yield folder
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def create_symlink_structure(base_path, output_path, debug: bool = False, show_tree: bool = False, force: bool = False):
|
|
63
|
+
"""Create a directory structure with shortcuts to latest submitted versions."""
|
|
64
|
+
|
|
65
|
+
output_path = Path(output_path)
|
|
66
|
+
output_path.mkdir(parents=True, exist_ok=True)
|
|
67
|
+
|
|
68
|
+
dbg = print if debug else (lambda *args, **kwargs: None)
|
|
69
|
+
|
|
70
|
+
if show_tree:
|
|
71
|
+
tree = sd.seedir(base_path, depthlimit=5, mask=mask, printout=False)
|
|
72
|
+
g = sd.fakedir_fromstring(tree)
|
|
73
|
+
g.seedir()
|
|
74
|
+
|
|
75
|
+
dbg(f"Scanning for folders in: {base_path}")
|
|
76
|
+
dbg(f"Output directory: {output_path}\n")
|
|
77
|
+
dbg(f"Force rebuild: {force}")
|
|
78
|
+
|
|
79
|
+
# Per-course mtime cache: {course_name: (src_latest, out_latest)}
|
|
80
|
+
course_mtime_cache = {}
|
|
81
|
+
|
|
82
|
+
processed = 0
|
|
83
|
+
for folder in iter_latest_versions(base_path, cutoff_mtime=None, dbg=dbg):
|
|
84
|
+
processed += 1
|
|
85
|
+
dbg(f"\nProcessing: {folder}")
|
|
86
|
+
dbg(f" Parts: {folder.parts}")
|
|
87
|
+
|
|
88
|
+
if "Version" in folder.parts[-1]:
|
|
89
|
+
dbg(f" ✓ Contains 'Version' in last part: {folder.parts[-1]}")
|
|
90
|
+
|
|
91
|
+
# Check if the version folder has any files or subdirectories
|
|
92
|
+
has_content = any(folder.iterdir())
|
|
93
|
+
if not has_content:
|
|
94
|
+
dbg(f" ✗ Skipping - folder is empty (no submitted work)")
|
|
95
|
+
continue
|
|
96
|
+
|
|
97
|
+
dbg(f" ✓ Folder has content")
|
|
98
|
+
|
|
99
|
+
# Extract the relevant parts of folder.parts
|
|
100
|
+
parts = folder.parts
|
|
101
|
+
|
|
102
|
+
# Find the indices for the structure we want
|
|
103
|
+
student_work_idx = next(i for i, p in enumerate(parts) if "Student Work" in p)
|
|
104
|
+
dbg(f" Student Work index: {student_work_idx}")
|
|
105
|
+
|
|
106
|
+
# Build the relative path: Subject / Assignment / Student Name (Version X)
|
|
107
|
+
relative_parts = parts[student_work_idx + 1:] # Skip "Student Work"
|
|
108
|
+
dbg(f" Relative parts: {relative_parts}")
|
|
109
|
+
|
|
110
|
+
# Find submitted files index to get student name
|
|
111
|
+
submitted_idx = next((i for i, p in enumerate(relative_parts) if "Submitted files" in p), None)
|
|
112
|
+
dbg(f" Submitted files index: {submitted_idx}")
|
|
113
|
+
|
|
114
|
+
if submitted_idx is not None and submitted_idx >= 0:
|
|
115
|
+
# The structure is: Course - Student Work / Submitted files / Student Name / Assignment / Version X
|
|
116
|
+
# We want: Course / Assignment / Student Name
|
|
117
|
+
|
|
118
|
+
# Get the course name (before "- Student Work") from the full parts (not relative_parts)
|
|
119
|
+
course_with_suffix = parts[student_work_idx] # e.g., "Cyber EPQ 2025-26 Extended A - Student Work"
|
|
120
|
+
course_name = course_with_suffix.replace(" - Student Work", "").strip()
|
|
121
|
+
|
|
122
|
+
# Get student name (after "Submitted files")
|
|
123
|
+
student_name = relative_parts[submitted_idx + 1]
|
|
124
|
+
|
|
125
|
+
# Get assignment name (between student name and Version folder)
|
|
126
|
+
assignment_parts = relative_parts[submitted_idx + 2:-1] # Exclude the Version folder
|
|
127
|
+
assignment_name = " - ".join(assignment_parts) if assignment_parts else "General"
|
|
128
|
+
|
|
129
|
+
version_num = folder.parts[-1]
|
|
130
|
+
|
|
131
|
+
dbg(f" Course: {course_name}")
|
|
132
|
+
dbg(f" Assignment: {assignment_name}")
|
|
133
|
+
dbg(f" Student name: {student_name}")
|
|
134
|
+
dbg(f" Version: {version_num}")
|
|
135
|
+
|
|
136
|
+
# Per-course mtime check (early exit before any shortcut work)
|
|
137
|
+
if course_name not in course_mtime_cache:
|
|
138
|
+
source_course_path = Path(*parts[:student_work_idx + 1]) # includes "... - Student Work"
|
|
139
|
+
output_course_path = output_path / course_name
|
|
140
|
+
src_mtime = get_latest_mtime(source_course_path)
|
|
141
|
+
out_mtime = get_latest_mtime(output_course_path)
|
|
142
|
+
course_mtime_cache[course_name] = (src_mtime, out_mtime)
|
|
143
|
+
dbg(f" Course mtime src={src_mtime}, out={out_mtime}")
|
|
144
|
+
else:
|
|
145
|
+
src_mtime, out_mtime = course_mtime_cache[course_name]
|
|
146
|
+
|
|
147
|
+
if not force and out_mtime >= src_mtime:
|
|
148
|
+
dbg(f" - Course '{course_name}' up to date; skipping")
|
|
149
|
+
continue
|
|
150
|
+
|
|
151
|
+
# Create output path: course/assignment/student
|
|
152
|
+
target_dir = output_path / course_name / assignment_name
|
|
153
|
+
shortcut_path = target_dir / (student_name + ".lnk")
|
|
154
|
+
dbg(f" Shortcut path: {shortcut_path}")
|
|
155
|
+
|
|
156
|
+
shortcut_path.parent.mkdir(parents=True, exist_ok=True)
|
|
157
|
+
|
|
158
|
+
# If force is True, always recreate; otherwise, skip if up to date
|
|
159
|
+
if shortcut_path.exists() and not force:
|
|
160
|
+
try:
|
|
161
|
+
existing_target = Path(shell.CreateShortCut(str(shortcut_path)).Targetpath)
|
|
162
|
+
if existing_target.resolve() == Path(folder).resolve():
|
|
163
|
+
dbg(" - Shortcut already up to date; skipping")
|
|
164
|
+
continue
|
|
165
|
+
else:
|
|
166
|
+
dbg(f" - Shortcut exists but points to {existing_target}; replacing")
|
|
167
|
+
shortcut_path.unlink(missing_ok=True)
|
|
168
|
+
except Exception as e:
|
|
169
|
+
dbg(f" - Could not read existing shortcut (will recreate): {e}")
|
|
170
|
+
elif shortcut_path.exists() and force:
|
|
171
|
+
dbg(" - Force enabled; recreating shortcut")
|
|
172
|
+
shortcut_path.unlink(missing_ok=True)
|
|
173
|
+
|
|
174
|
+
try:
|
|
175
|
+
shortcut = shell.CreateShortCut(str(shortcut_path))
|
|
176
|
+
shortcut.Targetpath = str(folder)
|
|
177
|
+
shortcut.WorkingDirectory = str(folder.parent)
|
|
178
|
+
shortcut.save()
|
|
179
|
+
dbg(f" ✓ Shortcut created/updated (points to {version_num})")
|
|
180
|
+
if not shortcut_path.exists():
|
|
181
|
+
raise Exception("Shortcut creation failed - file does not exist after save()")
|
|
182
|
+
except Exception as e:
|
|
183
|
+
print(f" ✗ Error creating shortcut: {e}")
|
|
184
|
+
print(f"\nStopping execution for debugging.")
|
|
185
|
+
raise
|
|
186
|
+
else:
|
|
187
|
+
dbg(f" ✗ Submitted index is None or <= 0")
|
|
188
|
+
else:
|
|
189
|
+
dbg(f" ✗ No 'Version' in last part")
|
|
190
|
+
|
|
191
|
+
dbg(f"\nProcessed latest version folders: {processed}")
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# shortcuts.py
|
|
2
|
+
# Provides create_shortcut for Windows .lnk shortcut creation
|
|
3
|
+
import win32com.client
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
def create_shortcut(target: str, shortcut_path: str, working_dir: str = None):
|
|
7
|
+
shell = win32com.client.Dispatch("WScript.Shell")
|
|
8
|
+
shortcut = shell.CreateShortCut(str(shortcut_path))
|
|
9
|
+
shortcut.Targetpath = str(target)
|
|
10
|
+
if working_dir:
|
|
11
|
+
shortcut.WorkingDirectory = str(working_dir)
|
|
12
|
+
shortcut.save()
|
|
13
|
+
if not Path(shortcut_path).exists():
|
|
14
|
+
raise Exception(f"Shortcut creation failed: {shortcut_path}")
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: submissionsync
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Create shortcuts to latest submitted MS teams assignment versions
|
|
5
|
+
Home-page: https://github.com/UTCSheffield/ms-teams-latest-submitted-version
|
|
6
|
+
Author: Your Name
|
|
7
|
+
Author-email: Martyn Eggleton <meggleton@utcsheffield.org.uk>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/UTCSheffield/ms-teams-latest-submitted-version
|
|
10
|
+
Keywords: submissions,shortcuts,assignments,windows
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: seedir>=0.4.0
|
|
15
|
+
Requires-Dist: pywin32>=302
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
18
|
+
Dynamic: author
|
|
19
|
+
Dynamic: home-page
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
|
|
23
|
+
# submissionsync
|
|
24
|
+
|
|
25
|
+
Create shortcuts to the latest submitted assignment versions from a hierarchical student work directory structure.
|
|
26
|
+
|
|
27
|
+
## Overview
|
|
28
|
+
|
|
29
|
+
`submissionsync` automates the organization of student submissions by creating shortcuts to only the latest version of each assignment. Perfect for managing large volumes of student work organized in the nested directories produced by "MS Teams Assignments".
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
- 🔗 Automatic shortcut creation to latest submission versions
|
|
34
|
+
- 📁 Intelligent filtering of Student Work directories
|
|
35
|
+
- ⚡ Modification time caching for performance
|
|
36
|
+
- 🔄 Force rebuild option for rechecking all submissions
|
|
37
|
+
- 🐛 Debug mode for troubleshooting
|
|
38
|
+
- 📊 Optional directory tree visualization
|
|
39
|
+
- 🖥️ Cross-platform Python module (shortcuts on Windows)
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install submissionsync
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Quick Start
|
|
48
|
+
|
|
49
|
+
### Using Defaults
|
|
50
|
+
|
|
51
|
+
Run with default paths:
|
|
52
|
+
```bash
|
|
53
|
+
submissionsync
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
This uses:
|
|
57
|
+
- **Source**: `~/UTC Sheffield`
|
|
58
|
+
- **Output**: `P:\Documents\Student Work - Latest Submissions`
|
|
59
|
+
|
|
60
|
+
### Custom Directories
|
|
61
|
+
|
|
62
|
+
Specify custom source and output paths:
|
|
63
|
+
```bash
|
|
64
|
+
submissionsync /path/to/student/work /path/to/output
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Usage
|
|
68
|
+
|
|
69
|
+
### Command Line Interface
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
submissionsync [SOURCE] [OUTPUT] [OPTIONS]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Arguments:**
|
|
76
|
+
- `SOURCE`: Source directory containing student work (optional, default: `~/UTC Sheffield`)
|
|
77
|
+
- `OUTPUT`: Output directory for shortcuts (optional, default: `P:\Documents\Student Work - Latest Submissions`)
|
|
78
|
+
|
|
79
|
+
**Options:**
|
|
80
|
+
```bash
|
|
81
|
+
--debug Show detailed processing information
|
|
82
|
+
--show-tree Display directory tree before processing
|
|
83
|
+
--force Force recreation of all shortcuts (ignore cache)
|
|
84
|
+
--version Show version and exit
|
|
85
|
+
--help Show help message and exit
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Examples
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Debug mode with verbose output
|
|
92
|
+
submissionsync --debug
|
|
93
|
+
|
|
94
|
+
# Force rebuild of all shortcuts
|
|
95
|
+
submissionsync --force
|
|
96
|
+
|
|
97
|
+
# Show directory tree and process
|
|
98
|
+
submissionsync --show-tree
|
|
99
|
+
|
|
100
|
+
# Custom paths with options
|
|
101
|
+
submissionsync /source/path /output/path --debug --force
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Module Usage
|
|
105
|
+
|
|
106
|
+
Use `submissionsync` as a Python library:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
python -m submissionsync
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Available Functions
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from submissionsync import (
|
|
116
|
+
mask, # Filter mask for relevant directories
|
|
117
|
+
get_latest_mtime, # Get latest modification time in path
|
|
118
|
+
iter_latest_versions, # Iterate over latest version folders
|
|
119
|
+
create_symlink_structure # Main function to create shortcuts
|
|
120
|
+
)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Directory Structure
|
|
124
|
+
|
|
125
|
+
The tool expects a structure like:
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
submissionsync/__init__.py
|
|
6
|
+
submissionsync/__main__.py
|
|
7
|
+
submissionsync/cli.py
|
|
8
|
+
submissionsync/core.py
|
|
9
|
+
submissionsync/shortcuts.py
|
|
10
|
+
submissionsync.egg-info/PKG-INFO
|
|
11
|
+
submissionsync.egg-info/SOURCES.txt
|
|
12
|
+
submissionsync.egg-info/dependency_links.txt
|
|
13
|
+
submissionsync.egg-info/entry_points.txt
|
|
14
|
+
submissionsync.egg-info/requires.txt
|
|
15
|
+
submissionsync.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
submissionsync
|