-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating documentation, exposing methods for package
- Loading branch information
Showing
9 changed files
with
183 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,5 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,97 @@ | ||
# gaurabda-calendar | ||
Python library for calculating panchanga calendar with vaisnava events. | ||
|
||
## Installation | ||
|
||
``` | ||
pip install gaurabda | ||
``` | ||
|
||
## Using | ||
|
||
Here are a few examples of code that you can try quickly. Examples are related | ||
to calculation of calendar. Before calendar calculation we need to specify | ||
location and start date. | ||
|
||
We can obtain location object basically in two ways: | ||
|
||
* create new location | ||
|
||
``` | ||
# create new location | ||
loc = gcal.GCLocation(data = { | ||
'latitude': 27.583, | ||
'longitude': 77.73, | ||
'tzname': '+5:30 Asia/Calcutta', | ||
'name': 'Vrindavan, India' | ||
}) | ||
``` | ||
|
||
List of all timezones can be obtained by calling `gcal.GetTimeZones()`. | ||
|
||
* find location in existing list | ||
|
||
``` | ||
# find existing location | ||
loc = gcal.FindLocation(city='Vrindavan') | ||
``` | ||
|
||
List of all countries `gcal.GetCountries()` and list of cities for given country: `gcal.GetLocationsForCountry('India')`. Function GetLocationsForCountry has optional parameter limit, that takes whole number limiting number of locations returned by this method. Default value is -1, that means there is no limit. | ||
|
||
|
||
Then we need create date object. | ||
|
||
``` | ||
today = gcal.Today() | ||
print(repr(today)) | ||
date1 = gcal.GCGregorianDate(text='24 apr 2017') | ||
print(repr(date1)) | ||
``` | ||
|
||
Constructor for GCGregorianDate contains more optional parameters: | ||
|
||
* **year**, **month**, **day** that are whole natural numbers, year between 1500 - 2500, month 1-12, day according given month | ||
* **shour** is from interval 0.0 up to 1.0 where 0.0 is mignight, 0.5 is noon (12:00 PM) and 1.0 is next midnight. | ||
* **tzone** is offset from UTC 0:00 in hours, so value +5.5 means offset 5:30, which is actual for India | ||
* **date** is existing GCGregorianDate object | ||
* **text** can be text form of date (e.g. '24 Apr 2017') | ||
|
||
Parameters can be combined with certain succession of evaluation. Parameters are evaluated in this order, where later parameter overrides previous values. | ||
|
||
* text | ||
* date | ||
* year | ||
* month | ||
* day | ||
* shour | ||
|
||
So for example, to get first day of current month, we may use: | ||
|
||
``` | ||
d = gcal.GCGregorianDate(date=gcal.Today(), day=1) | ||
``` | ||
|
||
Next step is to create calculation engine for calendar, execute calculation and write results to file: | ||
|
||
``` | ||
# create calculation engine and calculate | ||
tc = gcal.TCalendar() | ||
tc.CalculateCalendar(loc,today,365) | ||
# save results in various formats | ||
with open('calendar.txt','wt') as wf: | ||
tc.formatPlainText(wf) | ||
with open('test/calendar.rtf','wt') as wf: | ||
tc.formatRtf(wf) | ||
with open('test/calendar.html','wt') as wf: | ||
tc.writeHtml(wf) | ||
with open('test/calendar2.html','wt') as wf: | ||
tc.writeTableHtml(wf) | ||
with open('test/calendar.xml','wt') as wf: | ||
tc.writeXml(wf) | ||
``` | ||
|
||
Argument for formatPlainText/formatRtf/etc. is writer, so it can be any text stream from `io` module. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
from distutils.core import setup | ||
|
||
curr_ver = '0.7.4' | ||
|
||
setup( | ||
name = 'gaurabda', # How you named your package folder (MyLib) | ||
packages = ['gaurabda', 'gaurabda.GCEnums'], # Chose the same as "name" | ||
include_package_data = True, | ||
package_data = {'gaurabda': ['res/*.*']}, | ||
version = '0.7.3', # Start with a small number and increase it with every change you make | ||
version = curr_ver, # Start with a small number and increase it with every change you make | ||
license='MIT', # Chose a license from here: https://help.github.com/articles/licensing-a-repository | ||
description = 'Calculation of Gaurabda calendar (Gaudiya Vaishnava calendar)', # Give a short description about your library | ||
author = 'Gopal', # Type in your name | ||
author_email = '[email protected]', # Type in your E-Mail | ||
url = 'https://github.com/gopa810/gaurabda', # Provide either the link to your github or to your website | ||
download_url = 'https://github.com/gopa810/gaurabda-calendar/archive/0.7.3.tar.gz', # I explain this later on | ||
download_url = 'https://github.com/gopa810/gaurabda-calendar/archive/' + curr_ver + '.tar.gz', # I explain this later on | ||
keywords = ['gaurabda', 'vaisnava', 'vaishnava', 'ISKCON', 'GCAL'], # Keywords that define your package best | ||
install_requires=[ # I get to this in a second | ||
], | ||
|