Giter Club home page Giter Club logo

pyuoyweek's Introduction

pyuoyweek

pyuoyweek is a (much nicer) Python reimplementation of one of my previous projects, uoyweek. It gives the current date string as formatted by the University of York. For example, spr/2/thu would refer to Thursday on the 2nd week of Spring term.

Installation

pyuoyweek uses Python 3 -- it is not compatible with Python 2.
If you just want to use pyuoyweek, you can simply download uoyweek.py - it's all self-contained. If you'd like, you can copy uoyweek.py to a folder on your $PATH and rename it to uoyweek, basically turning it into a command that you'd call with uoyweek.
You can also clone the repository if you'd like to add new term dates (there's a helpful script in tools/ for that) or otherwise contribute :)

With Pip

Although pyuoyweek is not on pypi, you can install the latest version via pip with the following command:

pip install git+https://github.com/lukemoll/pyuoyweek.git

Usage

Simply run ./uoyweek.py or python3 uoyweek.py. More options can be found with the -h flag, such as lowercase (-l) or short output (-s).

As a library

You may want to use this in your own python projects instead of just calling the script - while the source is fairly straightforward, here are some points you may be interested in:

# uoyweek.py should be in the directory as the script you're importing it from
import uoyweek, date

Getting the week

period = uoyweek.getPeriod(date.today()) 

print(period.name) # term or holiday name
print(period.date) # start date of term or holiday

Getting the week number (terms)

if type(period) is Term:
    print("Week " + period.getWeekNum(date.today()))
    # If you're specifying something other than date.today(),
    # it needs to be the same date you provided to getPeriod()

Getting a formatted string

print(period.toString(date.today()))
# as with getWeekNum(), this needs to be the same date you 
# provided to getPeriod()

Using term dates directly

The dates list is also importable, and is in chronological order. If you select a Period from the list, you can assume that it ends at the start of the next Period in the list.

Building an executable

Although the python script with a shebang is arguably more portable than an executable, you can create one if you'd like:
With cython and gcc:

$ cython3 uoyweek.py --embed
$ ls *.c
uoyweek.c
$ gcc uoyweek.c -I<include directory for Python> -L<library containing libpython> -l<libpython* without the lib> -o uoyweek

Contributing

If you see anything that needs fixing, do check the issues to see if it's known and if anyone's working on it. If not, make an issue or even submit a PR!
Also, check out milestones to see what features are planned.

License

This project is licensed under the BSD 3-Clause license.

pyuoyweek's People

Contributors

lukemoll avatar

Watchers

 avatar  avatar

Forkers

aaronc81

pyuoyweek's Issues

Unit tests

Should check known dates to check for regressions/etc. Pass constructed DateTime objects to Python functions rather than faking time to the process.

Using BS4 and requests to get the current year's date

Thinking that Term Dates will keep the same formatting and just using BS4 and requests to get the current date.

Advantages

  • No need to manually upload new code as the term dates change

Disadvantages

  • Moving over to semesters will need a code rewrite (another reason to dislike them)
  • Requires two quite big requirements (make them development requirements)
  • Requires active internet connection

Let me know what you think. I'd happily subscribe to an ICS of the Week numbers.

Support semesterisation

Brought up in #6

From September 2023, the University academic year will be split into two semesters and for the majority of courses this will replace our current three term model.1

Since Semesters require different string formatting (Semester _) to terms (_ Term), they should probably be a separate class. Potentially some form of StudyPeriod should directly subclass Period, from which Semester and Term can both subclass.

Footnotes

  1. https://www.york.ac.uk/about/term-dates/ โ†ฉ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.