<s> from __future__ import absolute_import <EOL> from openpyxl . compat import safe_string , deprecated <EOL> from openpyxl . utils import ( <EOL> get_column_interval , <EOL> column_index_from_string , <EOL> ) <EOL> from openpyxl . descriptors import ( <EOL> Integer , <EOL> Float , <EOL> Bool , <EOL> Strict , <EOL> String , <EOL> Alias , <EOL> ) <EOL> from openpyxl . styles . styleable import StyleableObject , StyleArray <EOL> from openpyxl . utils . bound_dictionary import BoundDictionary <EOL> class Dimension ( Strict , StyleableObject ) : <EOL> """<STR_LIT>""" <EOL> __fields__ = ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , ) <EOL> index = Integer ( ) <EOL> hidden = Bool ( ) <EOL> outlineLevel = Integer ( allow_none = True ) <EOL> outline_level = Alias ( '<STR_LIT>' ) <EOL> collapsed = Bool ( ) <EOL> def __init__ ( self , index , hidden , outlineLevel , <EOL> collapsed , worksheet , visible = True , style = None ) : <EOL> super ( Dimension , self ) . __init__ ( sheet = worksheet , style_array = style ) <EOL> self . index = index <EOL> self . hidden = hidden <EOL> self . outlineLevel = outlineLevel <EOL> self . collapsed = collapsed <EOL> def __iter__ ( self ) : <EOL> for key in self . __fields__ : <EOL> value = getattr ( self , key ) <EOL> if value : <EOL> yield key , safe_string ( value ) <EOL> @ property <EOL> @ deprecated ( "<STR_LIT>" ) <EOL> def visible ( self ) : <EOL> return not self . hidden <EOL> class RowDimension ( Dimension ) : <EOL> """<STR_LIT>""" <EOL> __fields__ = Dimension . __fields__ + ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:s>' ) <EOL> r = Alias ( '<STR_LIT:index>' ) <EOL> s = Alias ( '<STR_LIT>' ) <EOL> ht = Float ( allow_none = True ) <EOL> height = Alias ( '<STR_LIT>' ) <EOL> thickBot = Bool ( ) <EOL> thickTop = Bool ( ) <EOL> def __init__ ( self , <EOL> worksheet , <EOL> index = <NUM_LIT:0> , <EOL> ht = None , <EOL> customHeight = None , <EOL> s = None , <EOL> customFormat = None , <EOL> hidden = False , <EOL> outlineLevel = <NUM_LIT:0> , <EOL> outline_level = None , <EOL> collapsed = False , <EOL> visible = None , <EOL> height = None , <EOL> r = None , <EOL> spans = None , <EOL> thickBot = None , <EOL> thickTop = None , <EOL> ** kw <EOL> ) : <EOL> if r is not None : <EOL> index = r <EOL> if height is not None : <EOL> ht = height <EOL> self . ht = ht <EOL> if visible is not None : <EOL> hidden = not visible <EOL> if outline_level is not None : <EOL> outlineLevel = outlineLevel <EOL> super ( RowDimension , self ) . __init__ ( index , hidden , outlineLevel , <EOL> collapsed , worksheet , style = s ) <EOL> @ property <EOL> def customFormat ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . has_style <EOL> @ property <EOL> def customHeight ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . ht is not None <EOL> class ColumnDimension ( Dimension ) : <EOL> """<STR_LIT>""" <EOL> width = Float ( allow_none = True ) <EOL> bestFit = Bool ( ) <EOL> auto_size = Alias ( '<STR_LIT>' ) <EOL> index = String ( ) <EOL> min = Integer ( allow_none = True ) <EOL> max = Integer ( allow_none = True ) <EOL> collapsed = Bool ( ) <EOL> __fields__ = Dimension . __fields__ + ( '<STR_LIT:width>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) <EOL> def __init__ ( self , <EOL> worksheet , <EOL> index = '<STR_LIT:A>' , <EOL> width = None , <EOL> bestFit = False , <EOL> hidden = False , <EOL> outlineLevel = <NUM_LIT:0> , <EOL> outline_level = None , <EOL> collapsed = False , <EOL> style = None , <EOL> min = None , <EOL> max = None , <EOL> customWidth = False , <EOL> visible = None , <EOL> auto_size = None , ) : <EOL> self . width = width <EOL> self . min = min <EOL> self . max = max <EOL> if visible is not None : <EOL> hidden = not visible <EOL> if auto_size is not None : <EOL> bestFit = auto_size <EOL> self . bestFit = bestFit <EOL> if outline_level is not None : <EOL> outlineLevel = outline_level <EOL> self . collapsed = collapsed <EOL> super ( ColumnDimension , self ) . __init__ ( index , hidden , outlineLevel , <EOL> collapsed , worksheet , style = style ) <EOL> @ property <EOL> def customWidth ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . width is not None <EOL> def __iter__ ( self ) : <EOL> for key in self . __fields__ : <EOL> if key == '<STR_LIT>' : <EOL> value = self . style_id <EOL> else : <EOL> value = getattr ( self , key ) <EOL> if value : <EOL> yield key , safe_string ( value ) <EOL> class DimensionHolder ( BoundDictionary ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , worksheet , reference = "<STR_LIT:index>" , default_factory = None ) : <EOL> self . worksheet = worksheet <EOL> super ( DimensionHolder , self ) . __init__ ( reference , default_factory ) <EOL> def group ( self , start , end = None , outline_level = <NUM_LIT:1> , hidden = False ) : <EOL> """<STR_LIT>""" <EOL> if end is None : <EOL> end = start <EOL> new_dim = self [ start ] <EOL> new_dim . outline_level = outline_level <EOL> new_dim . hidden = hidden <EOL> work_sequence = get_column_interval ( start , end ) [ <NUM_LIT:1> : ] <EOL> for column_letter in work_sequence : <EOL> if column_letter in self : <EOL> del self [ column_letter ] <EOL> new_dim . min , new_dim . max = map ( column_index_from_string , ( start , end ) ) </s>
