Skip to content

Commit

Permalink
Updatyye python-app.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
finarfin-ag authored Jul 24, 2024
1 parent c290b3b commit 62999ba
Showing 1 changed file with 1 addition and 39 deletions.
40 changes: 1 addition & 39 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
# Persian months months = ["فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند"] # Helper function to check if a year is a leap year in the Persian calendar def is_persian_leap_year(year): leaps = [1, 5, 9, 13, 17, 22, 26, 30] return (year % 33) in leaps # Helper function to calculate the next Persian date def next_persian_date(year, month, day): """Get the next Persian date.""" day += 1 if (month <= 6 and day > 31) or (month > 6 and month < 12 and day > 30): day = 1 month += 1 elif month == 12: if (is_persian_leap_year(year) and day > 30) or (not is_persian_leap_year(year) and day > 29): day = 1 month = 1 year += 1 return year, month, day # Function to convert English digits to Persian digits def to_persian_digits(number): english_to_persian = str.maketrans("0123456789", "۰۱۲۳۴۵۶۷۸۹") return str(number).translate(english_to_persian) # Start and end dates start_year, start_month, start_day = 1357, 11, 22 end_year, end_month, end_day = 1403, 4, 22 # Generate dates current_year, current_month, current_day = start_year, start_month, start_day dates = [] while (current_year < end_year) or (current_year == end_year and current_month < end_month) or (current_year == end_year and current_month == end_month and current_day <= end_day): date_str = f"{to_persian_digits(current_day)}/{months[current_month-1]}/{to_persian_digits(current_year)}" dates.append(date_str) current_year, current_month, current_day = next_persian_date(current_year, current_month, current_day) # Join dates with ' - ' result = ' - '.join(dates) print(result) # Persian months months = ["فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند"] # Helper function to check if a year is a leap year in the Persian calendar def is_persian_leap_year(year): leaps = [1, 5, 9, 13, 17, 22, 26, 30] return (year % 33) in leaps # Helper function to calculate the next Persian date def next_persian_date(year, month, day): """Get the next Persian date.""" day += 1 if (month <= 6 and day > 31) or (month > 6 and month < 12 and day > 30): day = 1 month += 1 elif month == 12: if (is_persian_leap_year(year) and day > 30) or (not is_persian_leap_year(year) and day > 29): day = 1 month = 1 year += 1 return year, month, day # Start and end dates start_year, start_month, start_day = 1357, 11, 22 end_year, end_month, end_day = 1403, 4, 22 # Generate dates current_year, current_month, current_day = start_year, start_month, start_day dates = [] while (current_year < end_year) or (current_year == end_year and current_month < end_month) or (current_year == end_year and current_month == end_month and current_day <= end_day): date_str = f"{current_day}/{months[current_month-1]}/{current_year}" dates.append(date_str) current_year, current_month, current_day = next_persian_date(current_year, current_month, current_day) # Join dates with ' - ' result = ' - '.join(dates) print(result)

0 comments on commit 62999ba

Please sign in to comment.