forked from china-testing/bazi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.py
executable file
·63 lines (51 loc) · 1.57 KB
/
common.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Author: 钉钉或微信pythontesting 钉钉群21734177
# CreateDate: 2019-2-21
import argparse
import collections
import pprint
import datetime
from bidict import bidict
from datas import *
from ganzhi import *
from sizi import summarys
def check_gan(gan, gans):
result = ''
if ten_deities[gan]['合'] in gans:
result += "合" + ten_deities[gan]['合']
if ten_deities[gan]['冲'] in gans:
result += "冲" + ten_deities[gan]['冲']
return result
def yinyang(item):
if item in Gan:
return '+' if Gan.index(item)%2 == 0 else '-'
else:
return '+' if Zhi.index(item)%2 == 0 else '-'
def yinyangs(zhis):
result = []
for item in zhis:
result.append(yinyang(item))
if set(result) == set('+'):
print("四柱全阳")
if set(result) == set('-'):
print("四柱全阴")
def get_empty(zhu, zhi):
empty = empties[zhu]
if zhi in empty:
return "空"
return ""
def get_zhi_detail(zhi, me, multi=1):
out = ''
for gan in zhi5[zhi]:
out = out + "{}{}{}{} ".format(gan, gan5[gan], zhi5[zhi][gan]*multi,
ten_deities[me][gan])
return out
def check_gong(zhis, n1, n2, me, hes, desc='三合拱'):
result = ''
if zhis[n1] + zhis[n2] in hes:
gong = hes[zhis[n1] + zhis[n2]]
if gong not in zhis:
result += "\t{}:{}{}-{}[{}]".format(
desc, zhis[n1], zhis[n2], gong, get_zhi_detail(gong, me))
return result