Functions | |
def | indent |
Variables | |
string | data |
int | headerwidth = 46 |
tuple | labels = ('First Name','Last Name','Age','Position') |
list | lumidata |
list | lumifooter = [('%-*s'%(24,'189'),'%-*s'%(10,'17.89'),'%-*s'%(10,'16.1'),'%-*s'%(20,'3.47'))] |
list | lumiheader = [('%-*s'%(30,'Lumi Sections'),'%-*s'%(46,'Luminosity'))] |
list | rows = [row.strip().split(',') for row in data.splitlines()] |
int | width = 10 |
def tablePrinter::indent | ( | rows, | |
hasHeader = False , |
|||
headerChar = '-' , |
|||
delim = ' | ' , |
|||
justify = 'center' , |
|||
separateRows = False , |
|||
prefix = '' , |
|||
postfix = '' , |
|||
wrapfunc = lambda x:x |
|||
) |
Indents a table by column. - rows: A sequence of sequences of items, one sequence per row. - hadHeader: True if the first row consists of the column's names. - headerChar: Character to be used for the row separator line (if hasHeader==True or separateRows==True). - delim: The column delimiter. - justify: Determines how are data justified in their column. Valid values are 'left','right','center'. - separateRows: True if rows are to be separated by a line of 'headerChar's. - prefix: A string prepended to each printed row. - postfix: A string appended to each printed row. - wrapfunc: A function f(text) for wrapping text; each element in the table is first wrapped by this function.
Definition at line 7 of file tablePrinter.py.
Referenced by CalibrationXML::addChild(), FWPSetTableManager::cellRenderer(), node_filter(), operator<<(), and edm::ParameterDescription< std::vector< ParameterSet > >::writeOneElementToCfi().
00008 :x): 00009 """ 00010 Indents a table by column. 00011 - rows: A sequence of sequences of items, one sequence per row. 00012 - hadHeader: True if the first row consists of the column's names. 00013 - headerChar: Character to be used for the row separator line 00014 (if hasHeader==True or separateRows==True). 00015 - delim: The column delimiter. 00016 - justify: Determines how are data justified in their column. 00017 Valid values are 'left','right','center'. 00018 - separateRows: True if rows are to be separated by a line of 'headerChar's. 00019 - prefix: A string prepended to each printed row. 00020 - postfix: A string appended to each printed row. 00021 - wrapfunc: A function f(text) for wrapping text; each element in the table is first wrapped by this function. 00022 """ 00023 #nested function 00024 #closure for breaking logical rows to physical, using wrapfunc 00025 def rowWrapper(row): 00026 newRows=[wrapfunc(item).split('\n') for item in row] 00027 #print 'newRows: ',newRows 00028 #print 'map result: ',map(None,*newRows) 00029 #print 'rowwrapped: ',[[substr or '' for substr in item] for item in map(None,*newRows)] 00030 return [[substr or '' for substr in item] for item in map(None,*newRows)] 00031 # break each logical row into one or more physical ones 00032 logicalRows = [rowWrapper(row) for row in rows] 00033 # columns of physical rows 00034 columns = map(None,*reduce(operator.add,logicalRows)) 00035 # get the maximum of each column by the string length of its items 00036 maxWidths = [max([len(str(item)) for item in column]) for column in columns] 00037 rowSeparator = headerChar * (len(prefix) + len(postfix) + sum(maxWidths) + len(delim)*(len(maxWidths)-1)) 00038 # select the appropriate justify method 00039 justify = {'center':str.center,'right':str.rjust,'left':str.ljust}[justify.lower()] 00040 output=cStringIO.StringIO() 00041 if separateRows: print >> output,rowSeparator 00042 for physicalRows in logicalRows: 00043 for row in physicalRows: 00044 print >> output, prefix+delim.join([justify(str(item),width) for (item,width) in zip(row,maxWidths)])+postfix 00045 if separateRows or hasHeader: print >> output, rowSeparator; hasHeader=False 00046 return output.getvalue() 00047
string tablePrinter::data |
00001 """John,Smith,24,Software Engineer 00002 Mary,Brohowski,23,Sales Manager 00003 Aristidis,Papageorgopoulos,28,Senior Reseacher"""
Definition at line 51 of file tablePrinter.py.
int tablePrinter::headerwidth = 46 |
Definition at line 71 of file tablePrinter.py.
tuple tablePrinter::labels = ('First Name','Last Name','Age','Position') |
Definition at line 50 of file tablePrinter.py.
00001 [\ 00002 ('%-*s'%(8,'run'),'%-*s'%(8,'first'),'%-*s'%(8,'last'),'%-*s'%(10,'delivered'),'%-*s'%(10,'recorded'),'%-*s'%(20,'recorded\nmypathdfdafddafd')),\ 00003 ['%d'%(132440),'%d'%(23),'%d'%(99),'%.2f'%(2.345),'%.2f'%(1.23),'%.2f'%(0.5678)],\ 00004 ['%d'%(132442),'%d'%(1),'%d'%(20),'%.2f'%(2.345),'%.2f'%(1.23),'%.2f'%(0.5678)],\ 00005 ['','%d'%(27),'%d'%(43),'%.2f'%(2.345),'%.2f'%(1.23),'%.2f'%(0.5678)]\ 00006 ]
Definition at line 64 of file tablePrinter.py.
list tablePrinter::lumifooter = [('%-*s'%(24,'189'),'%-*s'%(10,'17.89'),'%-*s'%(10,'16.1'),'%-*s'%(20,'3.47'))] |
Definition at line 73 of file tablePrinter.py.
list tablePrinter::lumiheader = [('%-*s'%(30,'Lumi Sections'),'%-*s'%(46,'Luminosity'))] |
Definition at line 70 of file tablePrinter.py.
Referenced by lumi::Lumi2DB::retrieveData().
list tablePrinter::rows = [row.strip().split(',') for row in data.splitlines()] |
Definition at line 54 of file tablePrinter.py.
int tablePrinter::width = 10 |
Definition at line 59 of file tablePrinter.py.
Referenced by AlignableDetUnit::addAlignmentPositionErrorFromRotation(), AlignableDet::addAlignmentPositionErrorFromRotation(), CustomParticleFactory::addCustomParticle(), OptoScanAlgorithm::analyse(), MuonGeometrySVGTemplate::analyze(), MuonTrackValidatorBase::BinLogX(), MTVHistoProducerAlgo::BinLogX(), ecaldqm::MESetTrend::book(), FWTrackResidualDetailView::build(), TrackerMap::build(), RPCGeometryBuilderFromCondDB::build(), PixelTopologyBuilder::build(), DTGeometryBuilderFromCondDB::buildChamber(), DTGeometryBuilderFromDDD::buildChamber(), RPCGeometryBuilderFromDDD::buildGeometry(), RPCGeometryParsFromDD::buildGeometry(), DTGeometryBuilderFromCondDB::buildLayer(), DTGeometryBuilderFromDDD::buildLayer(), DTGeometryBuilderFromDDD::buildSuperLayer(), DTGeometryBuilderFromCondDB::buildSuperLayer(), CastorPedestalAnalysis::CastorPedVal(), edm::DocFormatHelper::commentWidth(), TFParams::computePulseWidth(), HcalSiPMShape::computeShape(), boundSpan::computeSpan(), ForwardDetLayer::computeSurface(), DDHCalBarrelAlgo::constructInsideSector(), HICTrajectoryCorrector::correct(), FWTGeoRecoGeometryESProducer::createShape(), DreamSD::crystalWidth(), OptOMirror::detailedDeviatesLightRay(), OptOPlateSplitter::detailedTraversesLightRay(), OptOSensor2D::detailedTraversesLightRay(), OptOMirror::detailedTraversesLightRay(), RingMaker::determineExtensions(), TMatacq::doFit(), PrintGeomInfoAction::dumpPV(), RPCMonitorSync::endJob(), cms::HICSeedMeasurementEstimator::estimate(), DDTIBLayerAlgo_MTCC::execute(), DDTIBLayerAlgo::execute(), TrackerValidationVariables::fillHitQuantities(), SiStripMonitorTrack::fillMEs(), SiStripMonitorTrack::fillModMEs(), EcalCoder::findPedestal(), BeamMonitor::FitAndFill(), FWGUIManager::FWGUIManager(), SiPixelInformationExtractor::getHistosFromPath(), SiStripGainFromData::getPeakOfLandau(), OpticalObject::getPlate(), SiStripInformationExtractor::getSingleModuleHistos(), SiPixelInformationExtractor::getTrackerMapHistos(), OptOCubeSplitter::getUpperPlate(), CSCValidation::getWidth(), HcalPedestalAnalysis::HcalPedVal(), HcalSiPM::hitCells(), DreamSD::initMap(), edm::service::ELtsErrorLog::item(), CustomParticleFactory::loadCustomParticles(), DDDividedPolyhedraRho::makeDDLogicalPart(), DDDividedPolyconeRho::makeDDLogicalPart(), CastorDbHardcode::makeGain(), CastorDbHardcode::makePedestal(), CastorDbHardcode::makePedestalWidth(), FWTableManagerBase::maxWidthForColumns(), SiStripMonitorMuonHLT::Normalizer(), edm::service::operator<<(), MuonResiduals6DOFrphiFitter::plot(), MuonResiduals6DOFFitter::plot(), MuonResiduals5DOFFitter::plot(), TwoBowedSurfacesDeformation::positionCorrection(), RecoTauPiZeroProducer::print(), SiStripClusterToDigiProducer::process(), CastorClusterProducer::produce(), ShallowClustersProducer::produce(), SiPixelInformationExtractor::readStatusMessage(), CSGAction::resizeMenuEntry(), edm::DocFormatHelper::setAtLeast1(), edm::DocFormatHelper::setAtLeast2(), edm::DocFormatHelper::setAtLeast3(), SiStripHistoPlotter::setNewCondDBPlot(), SiStripHistoPlotter::setNewPlot(), SiPixelHistoPlotter::setNewPlot(), function::ZMuTrackFunction::setParameters(), function::ZMuStandaloneScaledFunction::setParameters(), function::ZMuTrackScaledFunction::setParameters(), dqmTnP::VoigtianPlusExponentialFitter::setup(), FWGUIManager::setWindowInfoFrom(), ecaldqm::MESetTrend::shift_(), ValidateGeometry::validateDTLayerGeometry(), and dqmTnP::VoigtianPlusExponentialFitter::VoigtianPlusExponentialFitter().