GithubHelp home page GithubHelp logo

pouriya / tir Goto Github PK

View Code? Open in Web Editor NEW
130.0 1.0 8.0 49 KB

Have time.ir in shell!

Home Page: http://time.ir

License: Other

Makefile 0.62% Python 99.38%
crawler time date calendar shell terminal iran iranian iranian-calendar

tir's Introduction

tir

Have time.ir in shell!

tir

Installation

Download

Using git:

~ $ git clone --depth 1 --branch 20.07.26 https://github.com/Pouriya/tir && cd tir
~/tir $

Using wget:

~ $ wget https://github.com/Pouriya/tir/archive/20.07.26.tar.gz && tar xf 20.07.26.tar.gz && cd tir-20.07.26
~/tir-20.07.26 $

Dependencies

First you need to have Python 3.^5 installed. Most of other dependencies are by default installed on most Linuxes.

  • setuptools
    On most linux distributions:
    ~ $ sudo apt install python3-setuptools
    On FreeBSD:
    ~ # pkg install py36-setuptools
  • requests
    On most linux distributions:
    ~ $ sudo apt install python3-requests
    On FreeBSD:
    ~ # pkg install py36-requests
  • lxml
    On most linux distributions:
    ~ $ sudo apt install python3-lxml
    On FreeBSD:
    ~ # pkg install py36-lxml
    Note that lxml itself needs libxml2 and libxslt to compile.

Note that on FreeBSD it's better to link your python3.* to python3:

~ # ln -s /usr/local/bin/python3.6 /usr/local/bin/python3

Or edit Makefile and first line of ./bin/crawler.py and place your own Python 3 command

Notification is not show for you?

just run this command to reinstall or install libraries to solve the problem:

~ $ sudo apt-get --reinstall install libnotify-bin notify-osd

install tir itself

On Linux distributions run:

~/path/to/tir $ sudo make install

On FreeBSD you need gmake instead of make:

~/path/to/tir # gmake install

Then you have tir command everywhere:

/x/y/z $ tir
Emruz: 3-Shanbeh  15   Aban(08)   1397   Pa'eez  
Today:  Tuesday   06 November(11) 2018   Autumn  
System time: 00:04:03
 ________  ________  ________  ________  ________  ________  ________
| Shanbe ||  Yek   ||   Do   ||   Se   || Chahar ||  Panj  || Jom'eh |
 ________  ________  ________  ________  ________  ________  ________ 
|        ||        ||        ||        ||        ||        ||        |
|   28   ||   29   ||   30   ||   01   ||   02   ||   03   ||   04   |
| 10  20 || 11  21 || 12  22 || 13  23 || 14  24 || 15  25 || 16  26 |
|________||________||________||________||________||________||________|
 ________  ________  ________  ________  ________  ________  ________ 
|        ||        ||        ||        ||        ||        ||        |
|   05   ||   06   ||   07   ||   08   ||   09   ||   10   ||   11   |
| 17  27 || 18  28 || 19  29 || 20  30 || 21  31 || 22  01 || 23  02 |
|________||________||________||________||________||________||________|
 ________  ________  ________  ________  ________  ________  ________ 
|        ||        ||        ||        ||        ||        ||        |
|   12   ||   13   ||   14   ||   15   ||   16   ||   17   ||   18   |
| 24  03 || 25  04 || 26  05 || 27  06 || 28  07 || 29  08 || 01  09 |
|________||________||________||________||________||________||________|
 ________  ________  ________  ________  ________  ________  ________ 
|        ||        ||        ||        ||        ||        ||        |
|   19   ||   20   ||   21   ||   22   ||   23   ||   24   ||   25   |
| 02  10 || 03  11 || 04  12 || 05  13 || 06  14 || 07  15 || 08  16 |
|________||________||________||________||________||________||________|
 ________  ________  ________  ________  ________  ________  ________ 
|        ||        ||        ||        ||        ||        ||        |
|   26   ||   27   ||   28   ||   29   ||   30   ||   01   ||   02   |
| 09  17 || 10  18 || 11  19 || 12  20 || 13  21 || 14  22 || 15  23 |
|________||________||________||________||________||________||________|

Powered by http://time.ir

Uninstallation

On Linux distributions run:

~/path/to/tir $ sudo make uninstall

On FreeBSD you need gmake instead of make:

~/path/to/tir # gmake uninstall

Arguments

root@codefather:~/tir $ tir -h
Usage: tir [options]

Options:
  -h, --help       show this help message and exit
  -s, --solar      Does not show solar date
  -g, --gregorian  Does not show gregorian date
  -c, --calendar   Does not show calendar
  -t, --time       Does not show time
  -C, --color      Does not show colored text
  -q, --quote      Does not notify for quote
  -H, --holidays   Does not notify for holidays
  -a, --about      shows program's description and exits
  -u, --update-cache  if cache data exists, updates its data

So for example tir -s -g -c -C -q -H will result:

Emruz: 3-Shanbeh  15   Aban(08)   1397   Pa'eez  

Powered by http://time.ir

Contributing

I love pull requests from everyone ! For more info see CONTRIBUTING.md file.

tir's People

Contributors

graymind75 avatar greatbahram avatar pouriya avatar tacrazymage avatar

Stargazers

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

Watchers

 avatar

tir's Issues

Adding type hints

Hi!
I think it's better to use typing hints. That makes code cleaner. See PEP 484.
For example, this part:

def transform_numeral_date(data):
    # for example '1397/12/6' or 2018-2-25 which is my birthday :)
    if data.find('/') != -1:
        _type = 'solar'
    else: # assume gregorian
        _type = 'gregorian'
    data = data.strip().replace('/', '-').split('-')
    (year, month, day) = (transform_number(data[0])
                         ,transform_number(data[1])
                         ,transform_number(data[2]))
    season = find_season(int(month), _type)
    return (year, season, month, day)

Converts to:

from typing import Tuple
def transform_numeral_date(data: str) -> Tuple[int, Tuple[str, int], int, int]:
    # for example '1397/12/6' or 2018-2-25 which is my birthday :)
    if data.find('/') != -1:
        _type = 'solar'
    else: # assume gregorian
        _type = 'gregorian'
    data = data.strip().replace('/', '-').split('-')
    (year, month, day) = (transform_number(data[0])
                         ,transform_number(data[1])
                         ,transform_number(data[2]))
    season = find_season(int(month), _type)
    return (year, season, month, day)

If you think that's OK, I can fix it.

tir.tir._TagNotFound: could not found HTML tag 'div' with attribute 'class' and value which should contain 'container top'

This error is raised while running the tir command:

Traceback (most recent call last):
File "/usr/local/bin/tir", line 555, in
main()
File "/usr/local/bin/tir", line 457, in main
transformed = HTMLParser(data, transformers).parse()
File "/usr/local/lib/python3.7/site-packages/tir-18.12.25-py3.7.egg/tir/tir.py", line 280, in parse
transform_data[name] = transformer(self.html)
File "/usr/local/bin/tir", line 84, in find_dates
container_top = search(html.body, 'div', 'class', ('container top',))
File "/usr/local/lib/python3.7/site-packages/tir-18.12.25-py3.7.egg/tir/tir.py", line 224, in search
raise _TagNotFound(tag, attr, val)
tir.tir._TagNotFound: could not found HTML tag 'div' with attribute 'class' and value which should contain 'container top'

An error occurred

Hi.
There is a problem with executing " tir "
Given error :

Traceback (most recent call last):
  File "/usr/local/bin/tir", line 619, in <module>
    main(data)
  File "/usr/local/bin/tir", line 508, in main
    transformed = HTMLParser(data, transformers).parse()
  File "/usr/local/lib/python3.8/dist-packages/tir-19.10.7-py3.8.egg/tir/tir.py", line 282, in parse
    transform_data[name] = transformer(self.html)
  File "/usr/local/bin/tir", line 97, in find_dates
    solar = find_date(rows, 'shamsi')
  File "/usr/local/bin/tir", line 107, in find_date
    (weekday, (year, month_name, day)) = transform_date(date)
  File "/usr/local/lib/python3.8/dist-packages/tir-19.10.7-py3.8.egg/tir/tir.py", line 61, in transform_date
    date = transform_date_with_string_month(data[1].strip())
  File "/usr/local/lib/python3.8/dist-packages/tir-19.10.7-py3.8.egg/tir/tir.py", line 85, in transform_date_with_string_month
    ,transform_month(date[1])
  File "/usr/local/lib/python3.8/dist-packages/tir-19.10.7-py3.8.egg/tir/tir.py", line 177, in transform_month
    raise ValueError('unknown solar month {!r}'.format(month))
ValueError: unknown solar month 'اَمرداد'

Easier way to install

Hi,
First of all, thank you for your effort in making this software.
But, I want to ask is there any easier way to install this software?
I read the README file and i got it that I have to install lots of dependencies for using this.
It's good to build a way to install with only one command an enjoy it.
thanks.

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.