Commit 30ebf2b4 authored by Adam P. Goucher's avatar Adam P. Goucher

Move genus list to separate file

parent 9fa56ee8
# This file defines the genera accepted by lifelib. Earlier genera take
# precedence over later genera, so (for example) the rule b3s23 belongs
# to the genus 'lifelike' rather than 'isotropic'.
genus_list = []
genus_list.append({'name': 'lifelike', 'regex': 'b0?1?2?3?4?5?6?7?8?s0?1?2?3?4?5?6?7?8?'})
genus_list.append({'name': 'generations', 'regex': 'g[1-9][0-9]*b1?2?3?4?5?6?7?8?s0?1?2?3?4?5?6?7?8?'})
genus_list.append({'name': 'isotropic', 'regex': 'b[0-9ceaiknjqrytwz-]*s[0-9ceaiknjqrytwz-]*'})
genus_list.append({'name': 'ltl', 'regex': 'r[234567]b[1-9][0-9]*t[1-9][0-9]*s[1-9][0-9]*t[1-9][0-9]*'})
import re
from importlib import import_module
from genuslist import genus_list
def obtain_genus(rulestring):
......@@ -24,3 +16,11 @@ def genus_to_module(genus):
m = import_module('.' + genus, __name__)
return m
def rule_property(rulestring, attribute):
m = genus_to_module(obtain_genus(rulestring))
attr = getattr(m, attribute)
if callable(attr):
attr = attr(rulestring)
return attr
# This file defines the genera accepted by lifelib. Earlier genera take
# precedence over later genera, so (for example) the rule b3s23 belongs
# to the genus 'lifelike' rather than 'isotropic'.
genus_list = []
genus_list.append({'name': 'lifelike', 'regex': 'b0?1?2?3?4?5?6?7?8?s0?1?2?3?4?5?6?7?8?'})
genus_list.append({'name': 'generations', 'regex': 'g[1-9][0-9]*b1?2?3?4?5?6?7?8?s0?1?2?3?4?5?6?7?8?'})
genus_list.append({'name': 'isotropic', 'regex': 'b[0-9ceaiknjqrytwz-]*s[0-9ceaiknjqrytwz-]*'})
genus_list.append({'name': 'ltl', 'regex': 'r[234567]b[1-9][0-9]*t[1-9][0-9]*s[1-9][0-9]*t[1-9][0-9]*'})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment