mirror of
https://github.com/muhac/chinese-holidays-calendar.git
synced 2025-02-17 17:59:48 +08:00
reformat code
This commit is contained in:
parent
78a33ffafd
commit
9f5ff96495
@ -18,7 +18,7 @@ jobs:
|
||||
ref: ${{ github.head_ref }}
|
||||
fetch-depth: 2
|
||||
|
||||
- name: Set up Python environment
|
||||
- name: Setup Python environment
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.9
|
||||
@ -28,11 +28,11 @@ jobs:
|
||||
python -m pip install --upgrade pip
|
||||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
||||
|
||||
- name: Run crawler
|
||||
- name: Run crawler script
|
||||
shell: bash
|
||||
run: python crawler.py
|
||||
|
||||
- name: Setup Go
|
||||
- name: Setup Go environment
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.19
|
||||
@ -40,7 +40,7 @@ jobs:
|
||||
- name: Go Build
|
||||
run: go build -o . main
|
||||
|
||||
- name: Generate ICS
|
||||
- name: Generate ICS files
|
||||
run: ./main
|
||||
|
||||
- name: Commit changes
|
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
@ -49,3 +49,11 @@ jobs:
|
||||
with:
|
||||
version: latest
|
||||
working-directory: .
|
||||
|
||||
pylint:
|
||||
name: Pylint
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: ricardochaves/python-lint@v1.4.0
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
subscription link of public holidays in mainland China
|
||||
|
||||
> Calendar data updated at 2:41 on September 16, 2022
|
||||
> Calendar data updated at 2:44 on September 20, 2022
|
||||
|
||||
## Demo
|
||||
|
||||
|
@ -3,8 +3,10 @@
|
||||
|
||||
数据格式
|
||||
节日名;放假日期;补班日期
|
||||
没有补班留空,“;”不可省略
|
||||
没有补班留空,“;” 不可省略
|
||||
|
||||
日期格式
|
||||
M.D,M.D-M.D
|
||||
支持多选“,”和区间“-”
|
||||
支持多选 “,” 和区间 “-”
|
||||
前一年的日期格式为 “0.X”
|
||||
X 为距离 1 月 1 日的天数
|
||||
|
@ -11,11 +11,11 @@ import (
|
||||
"main/parse/data/write"
|
||||
)
|
||||
|
||||
func newHandler(optional ...core.Holidays) Handler {
|
||||
if len(optional) == 0 {
|
||||
func newHandler(optionalData ...core.Holidays) Handler {
|
||||
if len(optionalData) == 0 {
|
||||
return handler{}
|
||||
}
|
||||
return handler{data: optional[0]}
|
||||
return handler{data: optionalData[0]}
|
||||
}
|
||||
|
||||
type handler struct {
|
||||
|
@ -18,17 +18,18 @@ func date(year int, date string) (result time.Time) {
|
||||
return
|
||||
}
|
||||
|
||||
func holidays(year int, daysRaw string) (result []time.Time) {
|
||||
if daysRaw == "" {
|
||||
func holidays(year int, days string) (result []time.Time) {
|
||||
if days == "" {
|
||||
return
|
||||
}
|
||||
|
||||
days := strings.Split(daysRaw, ",")
|
||||
for _, day := range days {
|
||||
for _, day := range strings.Split(days, ",") {
|
||||
if strings.Contains(day, "-") {
|
||||
period := strings.Split(day, "-")
|
||||
for d := date(year, period[0]); !d.After(date(year, period[1])); d = d.AddDate(0, 0, 1) {
|
||||
d := date(year, period[0])
|
||||
for !d.After(date(year, period[1])) {
|
||||
result = append(result, d)
|
||||
d = d.AddDate(0, 0, 1)
|
||||
}
|
||||
} else {
|
||||
result = append(result, date(year, day))
|
||||
|
@ -43,16 +43,16 @@ func (dw dataReader) Read() (result data.Input) {
|
||||
return
|
||||
}
|
||||
|
||||
result := data.InputRaw{
|
||||
res := data.InputRaw{
|
||||
Year: file.Year,
|
||||
Data: lines(raw),
|
||||
}
|
||||
if len(result.Data) == 0 {
|
||||
if len(res.Data) == 0 {
|
||||
log.Printf("No data in %s\n", file.Name)
|
||||
return
|
||||
}
|
||||
|
||||
resultChan <- result
|
||||
resultChan <- res
|
||||
}(f)
|
||||
}
|
||||
|
||||
@ -74,8 +74,8 @@ func (dw dataReader) fileList() (result []fileInfo) {
|
||||
}
|
||||
|
||||
return lo.FilterMap(files, func(file os.DirEntry, _ int) (fileInfo, bool) {
|
||||
yr, err := year(file.Name(), dw.File)
|
||||
isFile := err == nil && !file.IsDir()
|
||||
yr, e := year(file.Name(), dw.File)
|
||||
isFile := e == nil && !file.IsDir()
|
||||
return fileInfo{Name: file.Name(), Year: yr}, isFile
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user