<s> from __future__ import ( <EOL> absolute_import , <EOL> print_function , <EOL> unicode_literals , <EOL> ) <EOL> from pydocx . models import XmlModel , XmlCollection <EOL> from pydocx . openxml . wordprocessing . abstract_num import AbstractNum <EOL> from pydocx . openxml . wordprocessing . numbering_instance import NumberingInstance <EOL> class Numbering ( XmlModel ) : <EOL> XML_TAG = '<STR_LIT>' <EOL> elements = XmlCollection ( AbstractNum , NumberingInstance ) <EOL> def __init__ ( self , ** kwargs ) : <EOL> super ( Numbering , self ) . __init__ ( ** kwargs ) <EOL> self . _abstract_nums = { } <EOL> self . _nums = { } <EOL> for el in self . elements : <EOL> if isinstance ( el , AbstractNum ) : <EOL> self . _abstract_nums [ el . abstract_num_id ] = el <EOL> elif isinstance ( el , NumberingInstance ) : <EOL> self . _nums [ el . num_id ] = el <EOL> else : <EOL> raise AssertionError ( <EOL> '<STR_LIT>' . format ( <EOL> type = el . __class__ . __name__ , <EOL> ) <EOL> ) <EOL> def get_numbering_definition ( self , num_id ) : <EOL> num = self . _nums . get ( num_id ) <EOL> if not num : <EOL> return <EOL> return self . _abstract_nums . get ( num . abstract_num_id ) </s>
