Add starting point for Arabic lots

This commit is contained in:
Gergely Polonkai 2016-07-25 17:05:03 +02:00
parent c0711d512d
commit 316e6884f4
6 changed files with 4422 additions and 0 deletions

312
data/lots.py Normal file
View File

@ -0,0 +1,312 @@
# -*- coding: utf8
import re
import logging
from collections import OrderedDict
def get_planet_name(planet):
if planet == 'ASC':
return 'ASCENDANT'
if planet == 'S. Node':
return 'MOON_SOUTH_NODE'
if planet.upper() in known_planets:
return planet.upper()
return None
def get_planet_def(planet):
PLANET_NAME = 0
CUSP = 1
RULER = 2
SIGN = 3
SIGN_DEGREE = 4
SIGN_MINUTE = 5
HOUSE_RULER = 6
ARABIC_LOT = 7
PLANET_HOUSE_RULER = 8
planet_def = [
get_planet_name(planet), # 0, PLANET_NAME
0, # 1, CUSP
None, # 2, RULER
None, # 3, SIGN
0, # 4, SIGN_DEGREE
0, # 5, SIGN_MINUTE
0, # 6, HOUSE_RULER
None, # 7, ARABIC_LOT
None, # 8, PLANET_HOUSE_RULER
]
sign_match = re.match(r'^(\d{2})([A-Z]{2})(\d{2})$', planet)
if planet_def[PLANET_NAME] is None:
if planet.startswith('Ruler of ') and \
get_planet_name(planet[9:]) is not None:
planet_def[RULER] = get_planet_name(planet[9:])
elif planet.startswith('Ruler '):
m1 = re.match(r'Ruler (\d+)(st|nd|rd|th)', planet)
m2 = re.match(r"Ruler (\w+)'s house", planet)
if m1 is not None:
planet_def[HOUSE_RULER] = int(m1.groups()[0])
elif m2 is not None:
planet_def[PLANET_HOUSE_RULER] = get_planet_name(
m2.groups()[0])
if planet_def[PLANET_HOUSE_RULER] is None:
logging.error(
"Error: planet house ruler definition error: {}"
.format(planet))
return None
else:
logging.error(
"Error: House ruler definition problem: {}"
.format(planet))
return None
elif planet.startswith('Cusp '):
m = re.match(r'^Cusp (\d+)(st|nd|rd|th)', planet)
if m is None:
logging.error("Cusp definition problem: {}"
.format(planet))
return None
planet_def[CUSP] = int(m.groups()[0])
elif sign_match is not None:
degree, sign, minute = sign_match.groups()
planet_def[SIGN] = next(s for s in signs if s.startswith(sign))
planet_def[SIGN_DEGREE] = int(degree)
planet_def[SIGN_MINUTE] = int(minute)
elif planet.startswith('PO '):
p_lot = planet[3:]
if not any(x['c_name'] for y, x in lots.items()
if p_lot.upper() == x['c_name']):
logging.error("Error: Unknown lot: {}".format(planet))
return None
planet_def[ARABIC_LOT] = p_lot.upper()
else:
logging.error("Unknown planet definition: {}".format(planet))
return None
planet_def = map(lambda x: 'NONE' if x is None else x, planet_def)
return """
{{
GSWE_PLANET_{name},
{cusp},
GSWE_PLANET_{ruler},
GSWE_SIGN_{sign}, {sign_degree}, {sign_minute},
{house_ruler},
GSWE_ARABIC_LOT_{arabic_lot},
GSWE_PLANET_{planet_house_ruler}
}}""".format(
name=planet_def[PLANET_NAME],
cusp=planet_def[CUSP],
ruler=planet_def[RULER],
sign=planet_def[SIGN],
sign_degree=planet_def[SIGN_DEGREE],
sign_minute=planet_def[SIGN_MINUTE],
house_ruler=planet_def[HOUSE_RULER],
arabic_lot=planet_def[ARABIC_LOT],
planet_house_ruler=planet_def[PLANET_HOUSE_RULER],
)
with open('lots.txt', 'r') as f:
content = map(lambda line: line.strip(), f.readlines())
lots = OrderedDict()
c_names = set()
known_planets = [
'MC',
'VERTEX',
'MOON_NODE',
'MOON_APOGEE',
'SUN',
'MOON',
'MERCURY',
'VENUS',
'EARTH',
'MARS',
'JUPITER',
'SATURN',
'URANUS',
'NEPTUNE',
'PLUTO',
'CHIRON',
'CERES',
'PALLAS',
'JUNO',
'VESTA',
'PHOLUS',
'NESSUS',
'CHARIKLO',
'SEDNA',
'ERIS',
'DEJANIRA',
'CIRCE',
'ORCUS',
'ASBOLUS',
'HYGIEA',
]
signs = [
'ARIES',
'TAURUS',
'GEMINI',
'CANCER',
'LEO',
'VIRGO',
'LIBRA',
'SCORPIO',
'SAGITTARIUS',
'CAPRICORN',
'AQUARIUS',
'PISCES',
]
while content:
line = content.pop(0)
m = re.match('^([^=]+) = (.*)$', line)
if not m:
print("Error in line (no lot name): {}".format(line))
continue
lot_name, line = m.groups()
line = line.strip()
am_pm_rule = False
if re.search('AM.*::.*PM', line):
am_pm_rule = True
line = line.split(' :: ')[0]
s = re.search(' \([AP]M\)$', line)
if s is None:
print("Error in AM/PM line: {}".format(line))
continue
line = line[:-5]
m = re.match('^([^-+]+) ([+-]) ([^-+]+) ([+-]) ([^-+]+)$', line)
if not m:
print("Error in line (doesn't match): {}".format(line))
continue
m = m.groups()
if m[1] != '+' and m[3] != '-':
print("Error in line: {}".format(line))
continue
if lot_name in lots and not am_pm_rule:
print("Lot {} already exists!".format(lot_name))
continue
lot_name_def = re.sub(r'[^A-Z0-9_]', '',
re.sub(r'[ ,]+', '_', lot_name.upper()))
if lot_name_def in c_names:
print("Lot {} already exists in enum!".format(lot_name_def))
lots[lot_name] = {
"c_name": lot_name_def,
"planets": (m[0], m[2], m[4]),
"am_pm": am_pm_rule,
}
enum = '''typedef enum _GsweArabicLot {
GSWE_ARABIC_LOT_NONE,\n'''
defs = '''typedef struct _GsweArabicLotPart {
GswePlanet planet;
guint8 cusp;
GswePlanet ruler;
GsweZodiac fixed_sign;
guint8 fixed_degree;
guint8 fixed_minute;
guint8 house_ruler;
GsweArabicLot arabic_lot;
GswePlanet planet_house_ruler;
} GsweArabicLotPart;
typedef struct _GsweArabicLotRecord {
gchar *name;
gboolean am_pm_rule;
GsweArabicLotPart parts[3];
} GsweArabicLotRecord;
static const GsweArabicLotRecord known_lots[] = {
'''
for idx, (lot_name, lot) in enumerate(lots.items()):
if idx != 0:
enum += ',\n'
defs += '\n'
enum += ' GSWE_ARABIC_LOT_' + lot['c_name']
defs += ' // Record for enum value ' + lot['c_name'] + '''
{
"''' + lot_name + '''",
''' + ("TRUE" if lot['am_pm'] else "FALSE") + ''',
{'''
for pidx, planet in enumerate(lot['planets']):
defs += get_planet_def(planet)
if pidx != 2:
defs += ','
defs += '''\n }
},\n'''
defs += ''' {NULL}
};'''
enum += '\n} GsweArabicLot;'
print("""/* gswe-lots.h - Arabic lot definitions for SWE-GLib
*
* Copyright © 2013 Gergely Polonkai
*
* SWE-GLib is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* SWE-GLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GSWE_LOTS_H__
#define __GSWE_LOTS_H__
#include "gswe-types.h"
""" + enum + """
""" + defs + """
#endif /* __GSWE_LOTS_H__ */""")

109
data/lots.txt Normal file
View File

@ -0,0 +1,109 @@
Fortune = ASC + Moon - Sun (AM) :: ASC + Sun - Moon (PM)
Ability = ASC + Mars - Ruler of ASC
Abundance = ASC + Sun - Moon
Accident = ASC + Saturn - Mars
Accomplishment = ASC + Sun - Jupiter
Action/Reasoning = ASC + Mars - Mercury
Addiction = ASC + S. Node - Neptune
Administrators = ASC + Mars - Mercury
Agriculture = ASC + Saturn - Venus
Allegiance = ASC + Saturn - Sun
Ancestors/Relations = ASC + Mars - Saturn (AM) :: ASC + Saturn - Mars (PM)
Ancestral Heritage = ASC + Moon - Cusp 8th
Armies = ASC + Saturn - Mars
Art = ASC + Venus - Mercury
Assassination (1) = ASC + Ruler 12th - Neptune
Assassination (2) = Mars + Neptune - Uranus
Assurance = ASC + Jupiter - Mercury
Astrology = ASC + Uranus - Mercury
Bad Luck = ASC + PO Fortune - PO Spirit
Bankruptcy (1) = Jupiter + Neptune - Uranus
Bankruptcy (2) = Jupiter + Jupiter - Uranus
Beauty = ASC + Venus - Sun
Benific Change = ASC + Pluto - Jupiter
Benevolence = ASC + Jupiter - Pluto
Business Partnerships = ASC + Cusp 7th - Ruler 10th
Cancer = ASC + Neptune - Jupiter
Catastrophe (1) = ASC + Uranus - Sun
Catastrophe (2) = ASC + Uranus - Saturn
Caution = ASC + Neptune - Saturn
Children = ASC + Saturn - Jupiter (AM) :: ASC + Jupiter - Saturn (PM)
Commerce (1) = ASC + Mercury - Sun
Commerce (2) = ASC + Mars - Sun
Controversy = ASC + Jupiter - Mars
Corruptness = ASC + Neptune - Venus
Curiosity = ASC + Moon - Mercury
Damage = ASC + Neptune - Venus
Danger, Violence, Debt = ASC + Mercury - Saturn (AM) :: ASC + Saturn - Mercury (PM)
Daughters = ASC + Venus - Moon
Death = ASC + Cusp 8th - Moon
Death (Parents) = ASC + Jupiter - Saturn (AM) :: ASC + Saturn - Jupiter (PM)
Debt = ASC + Mercury - Saturn (AM) :: ASC + Saturn - Mercury (PM)
Desire, Sexual Attraction = ASC + Cusp 5th + Ruler 5th
Destiny = MC + Sun - Moon (AM) :: MC + Mooon - Sun (PM)
Destruction = ASC + Mars - Sun
Disease = ASC + Mars - Mercury
Divorce (1) = ASC + Venus - Cusp 7th
Divorce (2) = ASC + Cusp 7th - Saturn
Eccentricity = ASC + Mercury - Uranus
Energy, Sex Drive = ASC + Pluto - Venus
Expected Birth (1) = ASC + Ruler Moon's house - Moon
Expected Birth (2) = ASC + Venus - Moon
Fame = ASC + Jupiter - Sun (AM) :: ASC + Sun - Jupiter (PM)
Famous Friends = ASC + PO Fortune - Sun
Fascination = ASC + Venus - Uranus
Fate (Karma) = ASC + Saturn - Sun
Father = ASC + Sun - Saturn (AM) :: ASC + Saturn - Sun (PM)
Fraud = ASC + Neptune - Sun
Friends (1) = ASC + Moon - Venus
Friends (2) = ASC + Mercury - Moon
Friends (3) = ASC + Moon - Uranus
Genius = ASC + Sun - Neptune
Grandparents (1) = ASC + Jupiter - Cusp 2nd (AM) :: ASC + Cusp 2nd - Jupiter (PM)
Grandparents (2) = ASC + Saturn - Cusp 2nd (AM) :: ASC + Cusp 2nd - Saturn (PM)
Guidance = ASC + Neptune - Uranus
Happiness = ASC + Uranus - Jupiter
Homosexuality = ASC + Mars - Uranus
Horsemanship = ASC + Moon - Saturn
Identity = ASC + Saturn - Moon
Imprisonment = ASC + Sun - Neptune
Increase = ASC + Jupiter - Sun
Inheritance (1) = ASC + Moon - Saturn
Inheritance (2) = ASC + Jupiter - Venus
Journeys (Air) = ASC + Uranus - Cusp 9th
Journeys (Land) = ASC + Cusp 9th - Ruler 9th
Journeys (Water) = ASC + 15CA00 + Saturn (AM) :: ASC + Saturn - 15CA00 (PM)
Kings, Rulers = ASC + Moon - Mercury
Knowledge = ASC + Moon - Mercury (AM) :: ASC + Mercury - Moon (PM)
Life, Reincarnation = ASC + Saturn - Jupiter (AM) :: ASC + Jupiter - Saturn (PM)
Love = ASC + Venus - Sun
Lovers = Mars + Venus - Cusp 5th
Luck = ASC + Moon - Jupiter
Marriage = ASC + Cusp 7th - Venus
Marriage of Woman (1) = ASC + Saturn - Venus
Marriage of Woman (2) = ASC + Mars - Moon
Marriage of Man (1) = ASC + Venus - Saturn
Marriage of Man (2) = ASC + Venus - Sun
Mother = ASC + Moon - Saturn
Partners = ASC + Cusp 7th - Venus
Peril = ASC + Cusp 8th - Saturn (AM) :: ASC + Saturn - Cusp 8th (PM)
Possessions = ASC + Cusp 2nd - Ruler 2nd
Real Estate (Land) = ASC + Moon - Saturn (AM) :: ASC + Saturn - Moon (PM)
Real Estate (Investment) = ASC + Jupiter - Mercury (AM) :: ASC + Mercury - Jupiter (PM)
Secret Enemies = ASC + Moon - Saturn
Short Journeys = ASC + Cusp 3rd - Ruler 3rd
Siblings = ASC + Saturn - Jupiter
Sickness = ASC + Mars - Saturn
Son-in-Laws = ASC + Venus - Saturn (AM) :: ASC + Saturn - Venus (PM)
Sons = Cusp 4th + Moon - Sun
Spirit = ASC + Sun - Moon (AM) :: ASC + Moon - Sun (PM)
Success = ASC + Jupiter - PO Fortune (AM) :: ASC + PO Fortune - Jupiter (PM)
Success (Investment) = ASC + Venus - Saturn
Suicide (1) = ASC + Cusp 8th - Neptune
Suicide (2) = ASC + Jupiter - Neptune
Surgery = ASC + Saturn - Mars (AM) :: ASC + Mars - Saturn (PM)
Tragedy = ASC + Saturn - Sun
Unusual Events = ASC + Uranus - Moon
Victory = ASC + Jupiter - PO Spirit (AM) :: ASC + PO Spirit - Jupiter (PM)
Weddings, Legal Contracts = Cusp 9th + Cusp 3rd - Venus
Widowhood = ASC + 08LI50 - Neptune

View File

@ -25,6 +25,7 @@ INST_H_SRC_FILES = \
INST_H_BUILT_FILES = \ INST_H_BUILT_FILES = \
gswe-enumtypes.h \ gswe-enumtypes.h \
gswe-lots.h \
gswe-version.h \ gswe-version.h \
$(NULL) $(NULL)
@ -61,6 +62,7 @@ libswe_glib_2_0_la_SOURCES = \
gswe-timestamp.c \ gswe-timestamp.c \
gswe-enumtypes.c \ gswe-enumtypes.c \
gswe-version.c \ gswe-version.c \
gswe-lots.c \
$(NULL) $(NULL)
libswe_glib_2_0_la_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) -Wall libswe_glib_2_0_la_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) -Wall

3862
src/gswe-lots.c Normal file

File diff suppressed because it is too large Load Diff

136
src/gswe-lots.h Normal file
View File

@ -0,0 +1,136 @@
/* gswe-lots.h - Arabic lot definitions for SWE-GLib
*
* Copyright © 2013 Gergely Polonkai
*
* SWE-GLib is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* SWE-GLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GSWE_LOTS_H__
#define __GSWE_LOTS_H__
#include "gswe-types.h"
typedef enum _GsweArabicLot {
GSWE_ARABIC_LOT_NONE,
GSWE_ARABIC_LOT_FORTUNE,
GSWE_ARABIC_LOT_ABILITY,
GSWE_ARABIC_LOT_ABUNDANCE,
GSWE_ARABIC_LOT_ACCIDENT,
GSWE_ARABIC_LOT_ACCOMPLISHMENT,
GSWE_ARABIC_LOT_ACTIONREASONING,
GSWE_ARABIC_LOT_ADDICTION,
GSWE_ARABIC_LOT_ADMINISTRATORS,
GSWE_ARABIC_LOT_AGRICULTURE,
GSWE_ARABIC_LOT_ALLEGIANCE,
GSWE_ARABIC_LOT_ANCESTORSRELATIONS,
GSWE_ARABIC_LOT_ANCESTRAL_HERITAGE,
GSWE_ARABIC_LOT_ARMIES,
GSWE_ARABIC_LOT_ART,
GSWE_ARABIC_LOT_ASSASSINATION_1,
GSWE_ARABIC_LOT_ASSASSINATION_2,
GSWE_ARABIC_LOT_ASSURANCE,
GSWE_ARABIC_LOT_ASTROLOGY,
GSWE_ARABIC_LOT_BAD_LUCK,
GSWE_ARABIC_LOT_BANKRUPTCY_1,
GSWE_ARABIC_LOT_BANKRUPTCY_2,
GSWE_ARABIC_LOT_BEAUTY,
GSWE_ARABIC_LOT_BENIFIC_CHANGE,
GSWE_ARABIC_LOT_BENEVOLENCE,
GSWE_ARABIC_LOT_BUSINESS_PARTNERSHIPS,
GSWE_ARABIC_LOT_CANCER,
GSWE_ARABIC_LOT_CATASTROPHE_1,
GSWE_ARABIC_LOT_CATASTROPHE_2,
GSWE_ARABIC_LOT_CAUTION,
GSWE_ARABIC_LOT_CHILDREN,
GSWE_ARABIC_LOT_COMMERCE_1,
GSWE_ARABIC_LOT_COMMERCE_2,
GSWE_ARABIC_LOT_CONTROVERSY,
GSWE_ARABIC_LOT_CORRUPTNESS,
GSWE_ARABIC_LOT_CURIOSITY,
GSWE_ARABIC_LOT_DAMAGE,
GSWE_ARABIC_LOT_DANGER_VIOLENCE_DEBT,
GSWE_ARABIC_LOT_DAUGHTERS,
GSWE_ARABIC_LOT_DEATH,
GSWE_ARABIC_LOT_DEATH_PARENTS,
GSWE_ARABIC_LOT_DEBT,
GSWE_ARABIC_LOT_DESIRE_SEXUAL_ATTRACTION,
GSWE_ARABIC_LOT_DESTINY,
GSWE_ARABIC_LOT_DESTRUCTION,
GSWE_ARABIC_LOT_DISEASE,
GSWE_ARABIC_LOT_DIVORCE_1,
GSWE_ARABIC_LOT_DIVORCE_2,
GSWE_ARABIC_LOT_ECCENTRICITY,
GSWE_ARABIC_LOT_ENERGY_SEX_DRIVE,
GSWE_ARABIC_LOT_EXPECTED_BIRTH_1,
GSWE_ARABIC_LOT_EXPECTED_BIRTH_2,
GSWE_ARABIC_LOT_FAME,
GSWE_ARABIC_LOT_FAMOUS_FRIENDS,
GSWE_ARABIC_LOT_FASCINATION,
GSWE_ARABIC_LOT_FATE_KARMA,
GSWE_ARABIC_LOT_FATHER,
GSWE_ARABIC_LOT_FRAUD,
GSWE_ARABIC_LOT_FRIENDS_1,
GSWE_ARABIC_LOT_FRIENDS_2,
GSWE_ARABIC_LOT_FRIENDS_3,
GSWE_ARABIC_LOT_GENIUS,
GSWE_ARABIC_LOT_GRANDPARENTS_1,
GSWE_ARABIC_LOT_GRANDPARENTS_2,
GSWE_ARABIC_LOT_GUIDANCE,
GSWE_ARABIC_LOT_HAPPINESS,
GSWE_ARABIC_LOT_HOMOSEXUALITY,
GSWE_ARABIC_LOT_HORSEMANSHIP,
GSWE_ARABIC_LOT_IDENTITY,
GSWE_ARABIC_LOT_IMPRISONMENT,
GSWE_ARABIC_LOT_INCREASE,
GSWE_ARABIC_LOT_INHERITANCE_1,
GSWE_ARABIC_LOT_INHERITANCE_2,
GSWE_ARABIC_LOT_JOURNEYS_AIR,
GSWE_ARABIC_LOT_JOURNEYS_LAND,
GSWE_ARABIC_LOT_JOURNEYS_WATER,
GSWE_ARABIC_LOT_KINGS_RULERS,
GSWE_ARABIC_LOT_KNOWLEDGE,
GSWE_ARABIC_LOT_LIFE_REINCARNATION,
GSWE_ARABIC_LOT_LOVE,
GSWE_ARABIC_LOT_LOVERS,
GSWE_ARABIC_LOT_LUCK,
GSWE_ARABIC_LOT_MARRIAGE,
GSWE_ARABIC_LOT_MARRIAGE_OF_WOMAN_1,
GSWE_ARABIC_LOT_MARRIAGE_OF_WOMAN_2,
GSWE_ARABIC_LOT_MARRIAGE_OF_MAN_1,
GSWE_ARABIC_LOT_MARRIAGE_OF_MAN_2,
GSWE_ARABIC_LOT_MOTHER,
GSWE_ARABIC_LOT_PARTNERS,
GSWE_ARABIC_LOT_PERIL,
GSWE_ARABIC_LOT_POSSESSIONS,
GSWE_ARABIC_LOT_REAL_ESTATE_LAND,
GSWE_ARABIC_LOT_REAL_ESTATE_INVESTMENT,
GSWE_ARABIC_LOT_SECRET_ENEMIES,
GSWE_ARABIC_LOT_SHORT_JOURNEYS,
GSWE_ARABIC_LOT_SIBLINGS,
GSWE_ARABIC_LOT_SICKNESS,
GSWE_ARABIC_LOT_SONINLAWS,
GSWE_ARABIC_LOT_SONS,
GSWE_ARABIC_LOT_SPIRIT,
GSWE_ARABIC_LOT_SUCCESS,
GSWE_ARABIC_LOT_SUCCESS_INVESTMENT,
GSWE_ARABIC_LOT_SUICIDE_1,
GSWE_ARABIC_LOT_SUICIDE_2,
GSWE_ARABIC_LOT_SURGERY,
GSWE_ARABIC_LOT_TRAGEDY,
GSWE_ARABIC_LOT_UNUSUAL_EVENTS,
GSWE_ARABIC_LOT_VICTORY,
GSWE_ARABIC_LOT_WEDDINGS_LEGAL_CONTRACTS,
GSWE_ARABIC_LOT_WIDOWHOOD
} GsweArabicLot;
#endif /* __GSWE_LOTS_H__ */

View File

@ -33,6 +33,7 @@
#include "gswe-timestamp.h" #include "gswe-timestamp.h"
#include "gswe-moment.h" #include "gswe-moment.h"
#include "gswe-enumtypes.h" #include "gswe-enumtypes.h"
#include "gswe-lots.h"
typedef enum { typedef enum {
GSWE_ERROR_SUCCESS, GSWE_ERROR_SUCCESS,