Giter Site home page Giter Site logo

jgen's Introduction

JGen ๐Ÿ“”๏ธ

Generate a text-based journal from a template file.

Contents

Getting Started

  1. Clone this repository -
  • git clone https://github.com/harrison-broadbent/JGen.git
  1. Edit "template.txt", copy and paste an example from /templates, or use the placeholder template -
  • vim template.txt
  1. Run JGen and follow the prompts -
  • python3 JGen.py
  1. Inspect "journal.txt" -
  • vim journal.txt

Example

Given the following template (available as templates/template_weekly.txt) -

_____________________________
Week: WEEKNUM, Year: YY
DD_NAME, DD MM_NAME - +++++++
DD_NAME, DD MM_NAME

Todos: - - -

Plans: - - -

and running JGen for two entries gives us -

_____________________________
Week: 10, Year: 2021
Saturday, 13 March -
Saturday, 20 March

Todos:
	-
	-
	-

Plans:
	-
	-
	-


_____________________________
Week: 11, Year: 2021
Saturday, 20 March -
Saturday, 27 March

Todos:
	-
	-
	-

Plans:
	-
	-
	-

Lets break down what happened -

  1. JGen sets it's internal date - "today's" date, from your perspective.
  2. JGen runs through line 1 and line 2 of template.txt, replacing keywords with their corresponding information and then writing the output to journal.txt.
  3. At the end of line 2 there are seven + (plus) symbols
    • JGen removes these from the output, and increments the internal date counter by 7 days.
  4. JGen fills out line 3 with the new date information, then fills out the rest of the information for the first entry.
  5. It then repeats this for the second entry, carrying over the date from the end of the first entry.
  6. JGen halts, with journal.txt containing our final output.

Overview

JGen parses a given template file to generate a journal file.

JGen runs through the template file and replaces keywords with their actual values (dates - day/month/year etc.), for a specified number of entries.

Usage

The JGen Python script contains all the code for the parser. To get started:

  • Download the JGen script.

  • Create a template.txt file (or download and rename one of the examples in /templates), and place it in the same directory as the JGen Python script.

    • See Details below for more information on creating a template.

    • See an Example to walk through a specific example of a template file.

  • Run the JGen Python script, and input the number of times the template should be reproduced.

    • Ex: 365 entries for a daily journal spanning a year, 52 entries for a weekly journal
  • journal.txt will be populated with text based on the template and the number of entries specified.

Details

See the Example section below if you want to jump straight into seeing how JGen works, by walking though an example.

JGen parses the template file, replacing any of the reserved keywords, shown below, with their corresponding date values.

Part of the templating process is to indicate using a (+) symbol when to increment the internal date counter, which JGen picks up as it parses the file. It also strips all (+) symbols from the file.

Reserved Keywords

  • DD

    • The date number.
    • 01, 05, 10, 21 etc.
  • MM

    • The month number.
    • 01, 10, 12 etc.
  • YY

    • The year.
    • 2020, 2021 etc.
  • DD_NAME

    • The name of the day.
    • Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
  • MM_NAME

    • January, February etc.
  • DAYNUM

    • Day number of the year.
    • 123, 340 etc.
  • WEEKNUM

    • Week number of the year.
    • 13, 51 etc.
  • +

    • used to increment the internal date counter

    • will only increment after the entire line has been parsed

      • for example, parsing
      DD/MM/YY+ - DD/MM/YY
      

      would give

      21/02/2050 - 21/02/2050
      

      and not

      21/02/2050 - 28/02/2050
      

Gotchas

  • + can only be used to increment the date.

    • All + symbols are removed from the output.
    • ie. journal.txt file will never contain a + character
  • As mentioned in the "reserved keywords" section of this readme, the + characters are only interpreted at the end of a line.

    • Currently, to work around this, just place the second date on a new line (like in templates/template_weekly.txt)

    • For example, parsing

      DD/MM/YY+ - DD/MM/YY
      

      would give

      21/02/2050 - 21/02/2050
      

      and not

      21/02/2050 - 28/02/2050
      

jgen's People

Contributors

harrison-broadbent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

neuroradiology

jgen's Issues

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.