file.c 609 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542
  1. /* Generated by Cython 0.20.1 on Sun Mar 16 22:58:13 2014 */
  2. #define PY_SSIZE_T_CLEAN
  3. #ifndef CYTHON_USE_PYLONG_INTERNALS
  4. #ifdef PYLONG_BITS_IN_DIGIT
  5. #define CYTHON_USE_PYLONG_INTERNALS 0
  6. #else
  7. #include "pyconfig.h"
  8. #ifdef PYLONG_BITS_IN_DIGIT
  9. #define CYTHON_USE_PYLONG_INTERNALS 1
  10. #else
  11. #define CYTHON_USE_PYLONG_INTERNALS 0
  12. #endif
  13. #endif
  14. #endif
  15. #include "Python.h"
  16. #ifndef Py_PYTHON_H
  17. #error Python headers needed to compile C extensions, please install development version of Python.
  18. #elif PY_VERSION_HEX < 0x02040000
  19. #error Cython requires Python 2.4+.
  20. #else
  21. #define CYTHON_ABI "0_20_1"
  22. #include <stddef.h> /* For offsetof */
  23. #ifndef offsetof
  24. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  25. #endif
  26. #if !defined(WIN32) && !defined(MS_WINDOWS)
  27. #ifndef __stdcall
  28. #define __stdcall
  29. #endif
  30. #ifndef __cdecl
  31. #define __cdecl
  32. #endif
  33. #ifndef __fastcall
  34. #define __fastcall
  35. #endif
  36. #endif
  37. #ifndef DL_IMPORT
  38. #define DL_IMPORT(t) t
  39. #endif
  40. #ifndef DL_EXPORT
  41. #define DL_EXPORT(t) t
  42. #endif
  43. #ifndef PY_LONG_LONG
  44. #define PY_LONG_LONG LONG_LONG
  45. #endif
  46. #ifndef Py_HUGE_VAL
  47. #define Py_HUGE_VAL HUGE_VAL
  48. #endif
  49. #ifdef PYPY_VERSION
  50. #define CYTHON_COMPILING_IN_PYPY 1
  51. #define CYTHON_COMPILING_IN_CPYTHON 0
  52. #else
  53. #define CYTHON_COMPILING_IN_PYPY 0
  54. #define CYTHON_COMPILING_IN_CPYTHON 1
  55. #endif
  56. #if CYTHON_COMPILING_IN_PYPY
  57. #define Py_OptimizeFlag 0
  58. #endif
  59. #if PY_VERSION_HEX < 0x02050000
  60. typedef int Py_ssize_t;
  61. #define PY_SSIZE_T_MAX INT_MAX
  62. #define PY_SSIZE_T_MIN INT_MIN
  63. #define PY_FORMAT_SIZE_T ""
  64. #define CYTHON_FORMAT_SSIZE_T ""
  65. #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  66. #define PyInt_AsSsize_t(o) __Pyx_PyInt_As_int(o)
  67. #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \
  68. (PyErr_Format(PyExc_TypeError, \
  69. "expected index value, got %.200s", Py_TYPE(o)->tp_name), \
  70. (PyObject*)0))
  71. #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \
  72. !PyComplex_Check(o))
  73. #define PyIndex_Check __Pyx_PyIndex_Check
  74. #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
  75. #define __PYX_BUILD_PY_SSIZE_T "i"
  76. #else
  77. #define __PYX_BUILD_PY_SSIZE_T "n"
  78. #define CYTHON_FORMAT_SSIZE_T "z"
  79. #define __Pyx_PyIndex_Check PyIndex_Check
  80. #endif
  81. #if PY_VERSION_HEX < 0x02060000
  82. #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  83. #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
  84. #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
  85. #define PyVarObject_HEAD_INIT(type, size) \
  86. PyObject_HEAD_INIT(type) size,
  87. #define PyType_Modified(t)
  88. typedef struct {
  89. void *buf;
  90. PyObject *obj;
  91. Py_ssize_t len;
  92. Py_ssize_t itemsize;
  93. int readonly;
  94. int ndim;
  95. char *format;
  96. Py_ssize_t *shape;
  97. Py_ssize_t *strides;
  98. Py_ssize_t *suboffsets;
  99. void *internal;
  100. } Py_buffer;
  101. #define PyBUF_SIMPLE 0
  102. #define PyBUF_WRITABLE 0x0001
  103. #define PyBUF_FORMAT 0x0004
  104. #define PyBUF_ND 0x0008
  105. #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  106. #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  107. #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  108. #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  109. #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
  110. #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE)
  111. #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE)
  112. typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
  113. typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
  114. #endif
  115. #if PY_MAJOR_VERSION < 3
  116. #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  117. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
  118. PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  119. #define __Pyx_DefaultClassType PyClass_Type
  120. #else
  121. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  122. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
  123. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  124. #define __Pyx_DefaultClassType PyType_Type
  125. #endif
  126. #if PY_VERSION_HEX < 0x02060000
  127. #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict")
  128. #endif
  129. #if PY_MAJOR_VERSION >= 3
  130. #define Py_TPFLAGS_CHECKTYPES 0
  131. #define Py_TPFLAGS_HAVE_INDEX 0
  132. #endif
  133. #if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  134. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  135. #endif
  136. #if PY_VERSION_HEX < 0x02060000
  137. #define Py_TPFLAGS_HAVE_VERSION_TAG 0
  138. #endif
  139. #if PY_VERSION_HEX < 0x02060000 && !defined(Py_TPFLAGS_IS_ABSTRACT)
  140. #define Py_TPFLAGS_IS_ABSTRACT 0
  141. #endif
  142. #if PY_VERSION_HEX < 0x030400a1 && !defined(Py_TPFLAGS_HAVE_FINALIZE)
  143. #define Py_TPFLAGS_HAVE_FINALIZE 0
  144. #endif
  145. #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  146. #define CYTHON_PEP393_ENABLED 1
  147. #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \
  148. 0 : _PyUnicode_Ready((PyObject *)(op)))
  149. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
  150. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  151. #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
  152. #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
  153. #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
  154. #else
  155. #define CYTHON_PEP393_ENABLED 0
  156. #define __Pyx_PyUnicode_READY(op) (0)
  157. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
  158. #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  159. #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
  160. #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
  161. #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  162. #endif
  163. #if CYTHON_COMPILING_IN_PYPY
  164. #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
  165. #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
  166. #else
  167. #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
  168. #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \
  169. PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  170. #endif
  171. #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
  172. #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
  173. #if PY_MAJOR_VERSION >= 3
  174. #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
  175. #else
  176. #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
  177. #endif
  178. #if PY_MAJOR_VERSION >= 3
  179. #define PyBaseString_Type PyUnicode_Type
  180. #define PyStringObject PyUnicodeObject
  181. #define PyString_Type PyUnicode_Type
  182. #define PyString_Check PyUnicode_Check
  183. #define PyString_CheckExact PyUnicode_CheckExact
  184. #endif
  185. #if PY_VERSION_HEX < 0x02060000
  186. #define PyBytesObject PyStringObject
  187. #define PyBytes_Type PyString_Type
  188. #define PyBytes_Check PyString_Check
  189. #define PyBytes_CheckExact PyString_CheckExact
  190. #define PyBytes_FromString PyString_FromString
  191. #define PyBytes_FromStringAndSize PyString_FromStringAndSize
  192. #define PyBytes_FromFormat PyString_FromFormat
  193. #define PyBytes_DecodeEscape PyString_DecodeEscape
  194. #define PyBytes_AsString PyString_AsString
  195. #define PyBytes_AsStringAndSize PyString_AsStringAndSize
  196. #define PyBytes_Size PyString_Size
  197. #define PyBytes_AS_STRING PyString_AS_STRING
  198. #define PyBytes_GET_SIZE PyString_GET_SIZE
  199. #define PyBytes_Repr PyString_Repr
  200. #define PyBytes_Concat PyString_Concat
  201. #define PyBytes_ConcatAndDel PyString_ConcatAndDel
  202. #endif
  203. #if PY_MAJOR_VERSION >= 3
  204. #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  205. #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
  206. #else
  207. #define __Pyx_PyBaseString_Check(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj) || \
  208. PyString_Check(obj) || PyUnicode_Check(obj))
  209. #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
  210. #endif
  211. #if PY_VERSION_HEX < 0x02060000
  212. #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type)
  213. #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type)
  214. #endif
  215. #ifndef PySet_CheckExact
  216. #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
  217. #endif
  218. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  219. #if PY_MAJOR_VERSION >= 3
  220. #define PyIntObject PyLongObject
  221. #define PyInt_Type PyLong_Type
  222. #define PyInt_Check(op) PyLong_Check(op)
  223. #define PyInt_CheckExact(op) PyLong_CheckExact(op)
  224. #define PyInt_FromString PyLong_FromString
  225. #define PyInt_FromUnicode PyLong_FromUnicode
  226. #define PyInt_FromLong PyLong_FromLong
  227. #define PyInt_FromSize_t PyLong_FromSize_t
  228. #define PyInt_FromSsize_t PyLong_FromSsize_t
  229. #define PyInt_AsLong PyLong_AsLong
  230. #define PyInt_AS_LONG PyLong_AS_LONG
  231. #define PyInt_AsSsize_t PyLong_AsSsize_t
  232. #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
  233. #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  234. #define PyNumber_Int PyNumber_Long
  235. #endif
  236. #if PY_MAJOR_VERSION >= 3
  237. #define PyBoolObject PyLongObject
  238. #endif
  239. #if PY_VERSION_HEX < 0x030200A4
  240. typedef long Py_hash_t;
  241. #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  242. #define __Pyx_PyInt_AsHash_t PyInt_AsLong
  243. #else
  244. #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  245. #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
  246. #endif
  247. #if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
  248. #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  249. #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  250. #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
  251. #else
  252. #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
  253. (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
  254. (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
  255. (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  256. #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
  257. (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
  258. (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
  259. (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  260. #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
  261. (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
  262. (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
  263. (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
  264. #endif
  265. #if PY_MAJOR_VERSION >= 3
  266. #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
  267. #endif
  268. #if PY_VERSION_HEX < 0x02050000
  269. #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n)))
  270. #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  271. #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n)))
  272. #else
  273. #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n))
  274. #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  275. #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n))
  276. #endif
  277. #if PY_VERSION_HEX < 0x02050000
  278. #define __Pyx_NAMESTR(n) ((char *)(n))
  279. #define __Pyx_DOCSTR(n) ((char *)(n))
  280. #else
  281. #define __Pyx_NAMESTR(n) (n)
  282. #define __Pyx_DOCSTR(n) (n)
  283. #endif
  284. #ifndef CYTHON_INLINE
  285. #if defined(__GNUC__)
  286. #define CYTHON_INLINE __inline__
  287. #elif defined(_MSC_VER)
  288. #define CYTHON_INLINE __inline
  289. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  290. #define CYTHON_INLINE inline
  291. #else
  292. #define CYTHON_INLINE
  293. #endif
  294. #endif
  295. #ifndef CYTHON_RESTRICT
  296. #if defined(__GNUC__)
  297. #define CYTHON_RESTRICT __restrict__
  298. #elif defined(_MSC_VER) && _MSC_VER >= 1400
  299. #define CYTHON_RESTRICT __restrict
  300. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  301. #define CYTHON_RESTRICT restrict
  302. #else
  303. #define CYTHON_RESTRICT
  304. #endif
  305. #endif
  306. #ifdef NAN
  307. #define __PYX_NAN() ((float) NAN)
  308. #else
  309. static CYTHON_INLINE float __PYX_NAN() {
  310. /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and
  311. a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is
  312. a quiet NaN. */
  313. float value;
  314. memset(&value, 0xFF, sizeof(value));
  315. return value;
  316. }
  317. #endif
  318. #if PY_MAJOR_VERSION >= 3
  319. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  320. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  321. #else
  322. #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
  323. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
  324. #endif
  325. #ifndef __PYX_EXTERN_C
  326. #ifdef __cplusplus
  327. #define __PYX_EXTERN_C extern "C"
  328. #else
  329. #define __PYX_EXTERN_C extern
  330. #endif
  331. #endif
  332. #if defined(WIN32) || defined(MS_WINDOWS)
  333. #define _USE_MATH_DEFINES
  334. #endif
  335. #include <math.h>
  336. #define __PYX_HAVE__lib__Naked__toolshed__c__file
  337. #define __PYX_HAVE_API__lib__Naked__toolshed__c__file
  338. #ifdef _OPENMP
  339. #include <omp.h>
  340. #endif /* _OPENMP */
  341. #ifdef PYREX_WITHOUT_ASSERTIONS
  342. #define CYTHON_WITHOUT_ASSERTIONS
  343. #endif
  344. #ifndef CYTHON_UNUSED
  345. # if defined(__GNUC__)
  346. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  347. # define CYTHON_UNUSED __attribute__ ((__unused__))
  348. # else
  349. # define CYTHON_UNUSED
  350. # endif
  351. # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  352. # define CYTHON_UNUSED __attribute__ ((__unused__))
  353. # else
  354. # define CYTHON_UNUSED
  355. # endif
  356. #endif
  357. typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
  358. const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/
  359. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  360. #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
  361. #define __PYX_DEFAULT_STRING_ENCODING ""
  362. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  363. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  364. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) ( \
  365. (sizeof(type) < sizeof(Py_ssize_t)) || \
  366. (sizeof(type) > sizeof(Py_ssize_t) && \
  367. likely(v < (type)PY_SSIZE_T_MAX || \
  368. v == (type)PY_SSIZE_T_MAX) && \
  369. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN || \
  370. v == (type)PY_SSIZE_T_MIN))) || \
  371. (sizeof(type) == sizeof(Py_ssize_t) && \
  372. (is_signed || likely(v < (type)PY_SSIZE_T_MAX || \
  373. v == (type)PY_SSIZE_T_MAX))) )
  374. static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
  375. static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  376. #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
  377. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  378. #define __Pyx_PyBytes_FromString PyBytes_FromString
  379. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  380. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char*);
  381. #if PY_MAJOR_VERSION < 3
  382. #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
  383. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  384. #else
  385. #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
  386. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
  387. #endif
  388. #define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
  389. #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
  390. #define __Pyx_PyObject_FromUString(s) __Pyx_PyObject_FromString((char*)s)
  391. #define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((char*)s)
  392. #define __Pyx_PyByteArray_FromUString(s) __Pyx_PyByteArray_FromString((char*)s)
  393. #define __Pyx_PyStr_FromUString(s) __Pyx_PyStr_FromString((char*)s)
  394. #define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((char*)s)
  395. #if PY_MAJOR_VERSION < 3
  396. static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
  397. {
  398. const Py_UNICODE *u_end = u;
  399. while (*u_end++) ;
  400. return u_end - u - 1;
  401. }
  402. #else
  403. #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
  404. #endif
  405. #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
  406. #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
  407. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  408. #define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
  409. #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
  410. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  411. static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
  412. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  413. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
  414. #if CYTHON_COMPILING_IN_CPYTHON
  415. #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  416. #else
  417. #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  418. #endif
  419. #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
  420. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  421. static int __Pyx_sys_getdefaultencoding_not_ascii;
  422. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  423. PyObject* sys = NULL;
  424. PyObject* default_encoding = NULL;
  425. PyObject* ascii_chars_u = NULL;
  426. PyObject* ascii_chars_b = NULL;
  427. sys = PyImport_ImportModule("sys");
  428. if (sys == NULL) goto bad;
  429. default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
  430. if (default_encoding == NULL) goto bad;
  431. if (strcmp(PyBytes_AsString(default_encoding), "ascii") == 0) {
  432. __Pyx_sys_getdefaultencoding_not_ascii = 0;
  433. } else {
  434. const char* default_encoding_c = PyBytes_AS_STRING(default_encoding);
  435. char ascii_chars[128];
  436. int c;
  437. for (c = 0; c < 128; c++) {
  438. ascii_chars[c] = c;
  439. }
  440. __Pyx_sys_getdefaultencoding_not_ascii = 1;
  441. ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
  442. if (ascii_chars_u == NULL) goto bad;
  443. ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
  444. if (ascii_chars_b == NULL || strncmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
  445. PyErr_Format(
  446. PyExc_ValueError,
  447. "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
  448. default_encoding_c);
  449. goto bad;
  450. }
  451. }
  452. Py_XDECREF(sys);
  453. Py_XDECREF(default_encoding);
  454. Py_XDECREF(ascii_chars_u);
  455. Py_XDECREF(ascii_chars_b);
  456. return 0;
  457. bad:
  458. Py_XDECREF(sys);
  459. Py_XDECREF(default_encoding);
  460. Py_XDECREF(ascii_chars_u);
  461. Py_XDECREF(ascii_chars_b);
  462. return -1;
  463. }
  464. #endif
  465. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
  466. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  467. #else
  468. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  469. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  470. static char* __PYX_DEFAULT_STRING_ENCODING;
  471. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  472. PyObject* sys = NULL;
  473. PyObject* default_encoding = NULL;
  474. char* default_encoding_c;
  475. sys = PyImport_ImportModule("sys");
  476. if (sys == NULL) goto bad;
  477. default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
  478. if (default_encoding == NULL) goto bad;
  479. default_encoding_c = PyBytes_AS_STRING(default_encoding);
  480. __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
  481. strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
  482. Py_DECREF(sys);
  483. Py_DECREF(default_encoding);
  484. return 0;
  485. bad:
  486. Py_XDECREF(sys);
  487. Py_XDECREF(default_encoding);
  488. return -1;
  489. }
  490. #endif
  491. #endif
  492. #ifdef __GNUC__
  493. /* Test for GCC > 2.95 */
  494. #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
  495. #define likely(x) __builtin_expect(!!(x), 1)
  496. #define unlikely(x) __builtin_expect(!!(x), 0)
  497. #else /* __GNUC__ > 2 ... */
  498. #define likely(x) (x)
  499. #define unlikely(x) (x)
  500. #endif /* __GNUC__ > 2 ... */
  501. #else /* __GNUC__ */
  502. #define likely(x) (x)
  503. #define unlikely(x) (x)
  504. #endif /* __GNUC__ */
  505. static PyObject *__pyx_m;
  506. static PyObject *__pyx_d;
  507. static PyObject *__pyx_b;
  508. static PyObject *__pyx_empty_tuple;
  509. static PyObject *__pyx_empty_bytes;
  510. static int __pyx_lineno;
  511. static int __pyx_clineno = 0;
  512. static const char * __pyx_cfilenm= __FILE__;
  513. static const char *__pyx_filename;
  514. static const char *__pyx_f[] = {
  515. "file.pyx",
  516. };
  517. /*--- Type declarations ---*/
  518. #ifndef CYTHON_REFNANNY
  519. #define CYTHON_REFNANNY 0
  520. #endif
  521. #if CYTHON_REFNANNY
  522. typedef struct {
  523. void (*INCREF)(void*, PyObject*, int);
  524. void (*DECREF)(void*, PyObject*, int);
  525. void (*GOTREF)(void*, PyObject*, int);
  526. void (*GIVEREF)(void*, PyObject*, int);
  527. void* (*SetupContext)(const char*, int, const char*);
  528. void (*FinishContext)(void**);
  529. } __Pyx_RefNannyAPIStruct;
  530. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  531. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
  532. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  533. #ifdef WITH_THREAD
  534. #define __Pyx_RefNannySetupContext(name, acquire_gil) \
  535. if (acquire_gil) { \
  536. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
  537. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
  538. PyGILState_Release(__pyx_gilstate_save); \
  539. } else { \
  540. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
  541. }
  542. #else
  543. #define __Pyx_RefNannySetupContext(name, acquire_gil) \
  544. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  545. #endif
  546. #define __Pyx_RefNannyFinishContext() \
  547. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  548. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  549. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  550. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  551. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  552. #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  553. #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  554. #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  555. #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
  556. #else
  557. #define __Pyx_RefNannyDeclarations
  558. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  559. #define __Pyx_RefNannyFinishContext()
  560. #define __Pyx_INCREF(r) Py_INCREF(r)
  561. #define __Pyx_DECREF(r) Py_DECREF(r)
  562. #define __Pyx_GOTREF(r)
  563. #define __Pyx_GIVEREF(r)
  564. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  565. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  566. #define __Pyx_XGOTREF(r)
  567. #define __Pyx_XGIVEREF(r)
  568. #endif /* CYTHON_REFNANNY */
  569. #define __Pyx_XDECREF_SET(r, v) do { \
  570. PyObject *tmp = (PyObject *) r; \
  571. r = v; __Pyx_XDECREF(tmp); \
  572. } while (0)
  573. #define __Pyx_DECREF_SET(r, v) do { \
  574. PyObject *tmp = (PyObject *) r; \
  575. r = v; __Pyx_DECREF(tmp); \
  576. } while (0)
  577. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  578. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  579. #if CYTHON_COMPILING_IN_CPYTHON
  580. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  581. PyTypeObject* tp = Py_TYPE(obj);
  582. if (likely(tp->tp_getattro))
  583. return tp->tp_getattro(obj, attr_name);
  584. #if PY_MAJOR_VERSION < 3
  585. if (likely(tp->tp_getattr))
  586. return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
  587. #endif
  588. return PyObject_GetAttr(obj, attr_name);
  589. }
  590. #else
  591. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  592. #endif
  593. static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*proto*/
  594. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  595. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
  596. static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/
  597. static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
  598. PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
  599. const char* function_name); /*proto*/
  600. #if CYTHON_COMPILING_IN_CPYTHON
  601. #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o,n,NULL)
  602. static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
  603. PyTypeObject* tp = Py_TYPE(obj);
  604. if (likely(tp->tp_setattro))
  605. return tp->tp_setattro(obj, attr_name, value);
  606. #if PY_MAJOR_VERSION < 3
  607. if (likely(tp->tp_setattr))
  608. return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
  609. #endif
  610. return PyObject_SetAttr(obj, attr_name, value);
  611. }
  612. #else
  613. #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
  614. #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
  615. #endif
  616. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /*proto*/
  617. #if CYTHON_COMPILING_IN_CPYTHON
  618. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); /*proto*/
  619. #else
  620. #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
  621. #endif
  622. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /*proto*/
  623. static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
  624. static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
  625. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/
  626. #if CYTHON_COMPILING_IN_CPYTHON && (PY_VERSION_HEX >= 0x03020000 || PY_MAJOR_VERSION < 3 && PY_VERSION_HEX >= 0x02070000)
  627. static CYTHON_INLINE PyObject* __Pyx_PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name) {
  628. PyObject *res;
  629. PyTypeObject *tp = Py_TYPE(obj);
  630. #if PY_MAJOR_VERSION < 3
  631. if (unlikely(PyInstance_Check(obj)))
  632. return __Pyx_PyObject_GetAttrStr(obj, attr_name);
  633. #endif
  634. res = _PyType_Lookup(tp, attr_name);
  635. if (likely(res)) {
  636. descrgetfunc f = Py_TYPE(res)->tp_descr_get;
  637. if (!f) {
  638. Py_INCREF(res);
  639. } else {
  640. res = f(res, obj, (PyObject *)tp);
  641. }
  642. } else {
  643. PyErr_SetObject(PyExc_AttributeError, attr_name);
  644. }
  645. return res;
  646. }
  647. #else
  648. #define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n)
  649. #endif
  650. static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
  651. static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
  652. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
  653. static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
  654. #include <string.h>
  655. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/
  656. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/
  657. #if PY_MAJOR_VERSION >= 3
  658. #define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
  659. #else
  660. #define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
  661. #endif
  662. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
  663. #if CYTHON_COMPILING_IN_CPYTHON
  664. static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
  665. PyListObject* L = (PyListObject*) list;
  666. Py_ssize_t len = Py_SIZE(list);
  667. if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
  668. Py_INCREF(x);
  669. PyList_SET_ITEM(list, len, x);
  670. Py_SIZE(list) = len+1;
  671. return 0;
  672. }
  673. return PyList_Append(list, x);
  674. }
  675. #else
  676. #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
  677. #endif
  678. static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
  679. #define __Pyx_CyFunction_USED 1
  680. #include <structmember.h>
  681. #define __Pyx_CYFUNCTION_STATICMETHOD 0x01
  682. #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
  683. #define __Pyx_CYFUNCTION_CCLASS 0x04
  684. #define __Pyx_CyFunction_GetClosure(f) \
  685. (((__pyx_CyFunctionObject *) (f))->func_closure)
  686. #define __Pyx_CyFunction_GetClassObj(f) \
  687. (((__pyx_CyFunctionObject *) (f))->func_classobj)
  688. #define __Pyx_CyFunction_Defaults(type, f) \
  689. ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
  690. #define __Pyx_CyFunction_SetDefaultsGetter(f, g) \
  691. ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
  692. typedef struct {
  693. PyCFunctionObject func;
  694. PyObject *func_dict;
  695. PyObject *func_weakreflist;
  696. PyObject *func_name;
  697. PyObject *func_qualname;
  698. PyObject *func_doc;
  699. PyObject *func_globals;
  700. PyObject *func_code;
  701. PyObject *func_closure;
  702. PyObject *func_classobj; /* No-args super() class cell */
  703. void *defaults;
  704. int defaults_pyobjects;
  705. int flags;
  706. PyObject *defaults_tuple; /* Const defaults tuple */
  707. PyObject *defaults_kwdict; /* Const kwonly defaults dict */
  708. PyObject *(*defaults_getter)(PyObject *);
  709. PyObject *func_annotations; /* function annotations dict */
  710. } __pyx_CyFunctionObject;
  711. static PyTypeObject *__pyx_CyFunctionType = 0;
  712. #define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code) \
  713. __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
  714. static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
  715. int flags, PyObject* qualname,
  716. PyObject *self,
  717. PyObject *module, PyObject *globals,
  718. PyObject* code);
  719. static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
  720. size_t size,
  721. int pyobjects);
  722. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
  723. PyObject *tuple);
  724. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
  725. PyObject *dict);
  726. static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
  727. PyObject *dict);
  728. static int __Pyx_CyFunction_init(void);
  729. static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);
  730. static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
  731. PyObject *mkw, PyObject *modname, PyObject *doc); /*proto*/
  732. static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
  733. PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass); /*proto*/
  734. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /*proto*/
  735. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
  736. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
  737. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
  738. static int __Pyx_check_binary_version(void);
  739. typedef struct {
  740. int code_line;
  741. PyCodeObject* code_object;
  742. } __Pyx_CodeObjectCacheEntry;
  743. struct __Pyx_CodeObjectCache {
  744. int count;
  745. int max_count;
  746. __Pyx_CodeObjectCacheEntry* entries;
  747. };
  748. static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
  749. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  750. static PyCodeObject *__pyx_find_code_object(int code_line);
  751. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
  752. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  753. int py_line, const char *filename); /*proto*/
  754. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
  755. /* Module declarations from 'lib.Naked.toolshed.c.file' */
  756. #define __Pyx_MODULE_NAME "lib.Naked.toolshed.c.file"
  757. int __pyx_module_is_main_lib__Naked__toolshed__c__file = 0;
  758. /* Implementation of 'lib.Naked.toolshed.c.file' */
  759. static PyObject *__pyx_builtin_IOError;
  760. static PyObject *__pyx_builtin_open;
  761. static PyObject *__pyx_builtin_UnicodeEncodeError;
  762. static PyObject *__pyx_builtin_Exception;
  763. static PyObject *__pyx_builtin_RuntimeError;
  764. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_2IO___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_filepath); /* proto */
  765. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_filepath); /* proto */
  766. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_2append(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_text); /* proto */
  767. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_4append_utf8(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_text); /* proto */
  768. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_6gzip(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_text, PyObject *__pyx_v_compression_level); /* proto */
  769. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_8write(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_text); /* proto */
  770. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_10write_as(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_text, PyObject *__pyx_v_the_encoding); /* proto */
  771. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_12write_bin(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_binary_data); /* proto */
  772. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_14safe_write(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_text); /* proto */
  773. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_16safe_write_bin(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_file_data); /* proto */
  774. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_18write_utf8(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_text); /* proto */
  775. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_filepath); /* proto */
  776. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_2read(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
  777. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_4read_bin(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
  778. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_6read_as(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_the_encoding); /* proto */
  779. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_8readlines(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
  780. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_10readlines_as(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_dev_spec_encoding); /* proto */
  781. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_12readlines_utf8(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
  782. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_14read_gzip(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_encoding); /* proto */
  783. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_16read_utf8(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
  784. static char __pyx_k_a[] = "a";
  785. static char __pyx_k_e[] = "e";
  786. static char __pyx_k_f[] = "f";
  787. static char __pyx_k_r[] = "r";
  788. static char __pyx_k_w[] = "w";
  789. static char __pyx_k_IO[] = "IO";
  790. static char __pyx_k_gz[] = ".gz";
  791. static char __pyx_k_os[] = "os";
  792. static char __pyx_k_rb[] = "rb";
  793. static char __pyx_k_ue[] = "ue";
  794. static char __pyx_k_wb[] = "wb";
  795. static char __pyx_k_wt[] = "wt";
  796. static char __pyx_k__13[] = "";
  797. static char __pyx_k_doc[] = "__doc__";
  798. static char __pyx_k_ioe[] = "ioe";
  799. static char __pyx_k_sys[] = "sys";
  800. static char __pyx_k_NFKD[] = "NFKD";
  801. static char __pyx_k_UTF8[] = "UTF8";
  802. static char __pyx_k_data[] = "data";
  803. static char __pyx_k_exit[] = "__exit__";
  804. static char __pyx_k_gzip[] = "gzip";
  805. static char __pyx_k_init[] = "__init__";
  806. static char __pyx_k_line[] = "line";
  807. static char __pyx_k_main[] = "__main__";
  808. static char __pyx_k_mode[] = "mode";
  809. static char __pyx_k_name[] = "__name__";
  810. static char __pyx_k_open[] = "open";
  811. static char __pyx_k_path[] = "path";
  812. static char __pyx_k_read[] = "read";
  813. static char __pyx_k_self[] = "self";
  814. static char __pyx_k_test[] = "__test__";
  815. static char __pyx_k_text[] = "text";
  816. static char __pyx_k_utf8[] = "utf8";
  817. static char __pyx_k_UTF_8[] = "UTF-8";
  818. static char __pyx_k_close[] = "close";
  819. static char __pyx_k_debug[] = "debug";
  820. static char __pyx_k_enter[] = "__enter__";
  821. static char __pyx_k_utf_8[] = "utf_8";
  822. static char __pyx_k_write[] = "write";
  823. static char __pyx_k_append[] = "append";
  824. static char __pyx_k_codecs[] = "codecs";
  825. static char __pyx_k_decode[] = "decode";
  826. static char __pyx_k_encode[] = "encode";
  827. static char __pyx_k_exists[] = "exists";
  828. static char __pyx_k_import[] = "__import__";
  829. static char __pyx_k_module[] = "__module__";
  830. static char __pyx_k_reader[] = "reader";
  831. static char __pyx_k_stderr[] = "stderr";
  832. static char __pyx_k_writer[] = "writer";
  833. static char __pyx_k_IOError[] = "IOError";
  834. static char __pyx_k_UTF_8_2[] = "UTF_8";
  835. static char __pyx_k_os_path[] = "os.path";
  836. static char __pyx_k_prepare[] = "__prepare__";
  837. static char __pyx_k_read_as[] = "read_as";
  838. static char __pyx_k_utf_8_2[] = "utf-8";
  839. static char __pyx_k_appender[] = "appender";
  840. static char __pyx_k_encoding[] = "encoding";
  841. static char __pyx_k_endswith[] = "endswith";
  842. static char __pyx_k_filepath[] = "filepath";
  843. static char __pyx_k_qualname[] = "__qualname__";
  844. static char __pyx_k_read_bin[] = "read_bin";
  845. static char __pyx_k_write_as[] = "write_as";
  846. static char __pyx_k_Exception[] = "Exception";
  847. static char __pyx_k_IO___init[] = "IO.__init__";
  848. static char __pyx_k_data_list[] = "data_list";
  849. static char __pyx_k_file_data[] = "file_data";
  850. static char __pyx_k_metaclass[] = "__metaclass__";
  851. static char __pyx_k_norm_data[] = "norm_data";
  852. static char __pyx_k_norm_line[] = "norm_line";
  853. static char __pyx_k_norm_text[] = "norm_text";
  854. static char __pyx_k_normalize[] = "normalize";
  855. static char __pyx_k_read_gzip[] = "read_gzip";
  856. static char __pyx_k_read_utf8[] = "read_utf8";
  857. static char __pyx_k_readlines[] = "readlines";
  858. static char __pyx_k_write_bin[] = "write_bin";
  859. static char __pyx_k_DEBUG_FLAG[] = "DEBUG_FLAG";
  860. static char __pyx_k_FileReader[] = "FileReader";
  861. static char __pyx_k_FileWriter[] = "FileWriter";
  862. static char __pyx_k_bin_reader[] = "bin_reader";
  863. static char __pyx_k_bin_writer[] = "bin_writer";
  864. static char __pyx_k_safe_write[] = "safe_write";
  865. static char __pyx_k_textstring[] = "textstring";
  866. static char __pyx_k_uni_reader[] = "uni_reader";
  867. static char __pyx_k_write_utf8[] = "write_utf8";
  868. static char __pyx_k_append_utf8[] = "append_utf8";
  869. static char __pyx_k_binary_data[] = "binary_data";
  870. static char __pyx_k_file_exists[] = "file_exists";
  871. static char __pyx_k_gzip_reader[] = "gzip_reader";
  872. static char __pyx_k_gzip_writer[] = "gzip_writer";
  873. static char __pyx_k_unicodedata[] = "unicodedata";
  874. static char __pyx_k_RuntimeError[] = "RuntimeError";
  875. static char __pyx_k_readlines_as[] = "readlines_as";
  876. static char __pyx_k_the_encoding[] = "the_encoding";
  877. static char __pyx_k_compresslevel[] = "compresslevel";
  878. static char __pyx_k_Naked_settings[] = "Naked.settings";
  879. static char __pyx_k_readlines_utf8[] = "readlines_utf8";
  880. static char __pyx_k_safe_write_bin[] = "safe_write_bin";
  881. static char __pyx_k_system_default[] = "system_default";
  882. static char __pyx_k_FileReader_read[] = "FileReader.read";
  883. static char __pyx_k_FileWriter_gzip[] = "FileWriter.gzip";
  884. static char __pyx_k_FileWriter_write[] = "FileWriter.write";
  885. static char __pyx_k_FileReader___init[] = "FileReader.__init__";
  886. static char __pyx_k_FileWriter___init[] = "FileWriter.__init__";
  887. static char __pyx_k_FileWriter_append[] = "FileWriter.append";
  888. static char __pyx_k_compression_level[] = "compression_level";
  889. static char __pyx_k_dev_spec_encoding[] = "dev_spec_encoding";
  890. static char __pyx_k_FileReader_read_as[] = "FileReader.read_as";
  891. static char __pyx_k_UnicodeEncodeError[] = "UnicodeEncodeError";
  892. static char __pyx_k_modified_text_list[] = "modified_text_list";
  893. static char __pyx_k_FileReader_read_bin[] = "FileReader.read_bin";
  894. static char __pyx_k_FileWriter_write_as[] = "FileWriter.write_as";
  895. static char __pyx_k_FileReader_read_gzip[] = "FileReader.read_gzip";
  896. static char __pyx_k_FileReader_read_utf8[] = "FileReader.read_utf8";
  897. static char __pyx_k_FileReader_readlines[] = "FileReader.readlines";
  898. static char __pyx_k_FileWriter_write_bin[] = "FileWriter.write_bin";
  899. static char __pyx_k_FileWriter_safe_write[] = "FileWriter.safe_write";
  900. static char __pyx_k_FileWriter_write_utf8[] = "FileWriter.write_utf8";
  901. static char __pyx_k_Naked_toolshed_system[] = "Naked.toolshed.system";
  902. static char __pyx_k_FileWriter_append_utf8[] = "FileWriter.append_utf8";
  903. static char __pyx_k_FileReader_readlines_as[] = "FileReader.readlines_as";
  904. static char __pyx_k_FileReader_readlines_utf8[] = "FileReader.readlines_utf8";
  905. static char __pyx_k_FileWriter_safe_write_bin[] = "FileWriter.safe_write_bin";
  906. static char __pyx_k_lib_Naked_toolshed_c_file[] = "lib.Naked.toolshed.c.file";
  907. static char __pyx_k_Naked_Framework_Error_Unable_to[] = "Naked Framework Error: Unable to append text to the file with the append() method (Naked.toolshed.file.py).";
  908. static char __pyx_k_Naked_Framework_Error_unable_to[] = "Naked Framework Error: unable to gzip compress the file with the gzip method (Naked.toolshed.file.py).";
  909. static char __pyx_k_The_file_specified_for_the_text[] = "The file specified for the text append does not exist (Naked.toolshed.file.py:append).";
  910. static char __pyx_k_Users_ces_Desktop_code_naked_li[] = "/Users/ces/Desktop/code/naked/lib/Naked/toolshed/c/file.pyx";
  911. static char __pyx_k_The_text_encoding_was_not_specif[] = "The text encoding was not specified as an argument to the write_as() method (Naked.toolshed.file.py:write_as).";
  912. static char __pyx_k_The_text_file_encoding_was_not_s[] = "The text file encoding was not specified as an argument to the read_as method (Naked.toolshed.file.py:read_as).";
  913. static char __pyx_k_Naked_Framework_Error_Unable_to_2[] = "Naked Framework Error: Unable to append text to the file with the append_utf8 method (Naked.toolshed.file.py).";
  914. static char __pyx_k_Naked_Framework_Error_Unable_to_3[] = "Naked Framework Error: Unable to write to requested file with the write() method (Naked.toolshed.file.py).";
  915. static char __pyx_k_Naked_Framework_Error_Unable_to_4[] = "Naked Framework Error: Unable to write binary data to file with the write_bin method (Naked.toolshed.file.py).";
  916. static char __pyx_k_Naked_Framework_Error_Unable_to_5[] = "Naked Framework Error: Unable to write to requested file with the safe_write() method (Naked.toolshed.file.py).";
  917. static char __pyx_k_Naked_Framework_Error_Unable_to_6[] = "Naked Framework Error: Unable to write to requested file with the safe_write_bin() method (Naked.toolshed.file.py).";
  918. static char __pyx_k_Naked_Framework_Error_Unable_to_7[] = "Naked Framework Error: Unable to open file for write with the write_utf8() method (Naked.toolshed.file.py).";
  919. static char __pyx_k_Naked_Framework_Error_Unable_to_8[] = "Naked Framework Error: Unable to write UTF-8 encoded text to file with the write_utf8() method (Naked.toolshed.file.py).";
  920. static char __pyx_k_Naked_Framework_Error_Unable_to_9[] = "Naked Framework Error: Unable to read text from the requested file with the read() method (Naked.toolshed.file.py).";
  921. static char __pyx_k_Naked_Framework_Error_unable_to_2[] = "Naked Framework Error: unable to write file with the specified encoding using the write_as() method (Naked.toolshed.file.py).";
  922. static char __pyx_k_Naked_Framework_Error_unable_to_3[] = "Naked Framework Error: unable to read lines in the specified encoding with the readlines_as method (Naked.toolshed.file.py).";
  923. static char __pyx_k_Naked_Framework_Error_unable_to_4[] = "Naked Framework Error: unable to read lines in the unicode file with the readlines_utf8 method (Naked.toolshed.file.py)";
  924. static char __pyx_k_The_file_specified_for_the_text_2[] = "The file specified for the text append does not exist (Naked.toolshed.file.py:append_utf8).";
  925. static char __pyx_k_Naked_Framework_Error_Unable_to_10[] = "Naked Framework Error: Unable to read the binary data from the file with the read_bin method (Naked.toolshed.file.py).";
  926. static char __pyx_k_Naked_Framework_Error_Unable_to_11[] = "Naked Framework Error: Unable to read the file with the developer specified text encoding with the read_as method (Naked.toolshed.file.py).";
  927. static char __pyx_k_Naked_Framework_Error_Unable_to_12[] = "Naked Framework Error: Unable to read text from the requested file with the readlines() method (Naked.toolshed.file.py).";
  928. static char __pyx_k_Naked_Framework_Error_Unable_to_13[] = "Naked Framework Error: Unable to read from the gzip compressed file with the read_gzip() method (Naked.toolshed.file.py).";
  929. static char __pyx_k_Naked_Framework_Error_Unable_to_14[] = "Naked Framework Error: Unable to open file for read with read_utf8() method (Naked.toolshed.file.py).";
  930. static char __pyx_k_Naked_Framework_Error_Unable_to_15[] = "Naked Framework Error: Unable to read the file with UTF-8 encoding using the read_utf8() method (Naked.toolshed.file.py).";
  931. static char __pyx_k_The_text_file_encoding_was_not_s_2[] = "The text file encoding was not specified as an argument to the readlines_as method (Naked.toolshed.file.py:readlines_as).";
  932. static PyObject *__pyx_n_s_DEBUG_FLAG;
  933. static PyObject *__pyx_n_s_Exception;
  934. static PyObject *__pyx_n_s_FileReader;
  935. static PyObject *__pyx_n_s_FileReader___init;
  936. static PyObject *__pyx_n_s_FileReader_read;
  937. static PyObject *__pyx_n_s_FileReader_read_as;
  938. static PyObject *__pyx_n_s_FileReader_read_bin;
  939. static PyObject *__pyx_n_s_FileReader_read_gzip;
  940. static PyObject *__pyx_n_s_FileReader_read_utf8;
  941. static PyObject *__pyx_n_s_FileReader_readlines;
  942. static PyObject *__pyx_n_s_FileReader_readlines_as;
  943. static PyObject *__pyx_n_s_FileReader_readlines_utf8;
  944. static PyObject *__pyx_n_s_FileWriter;
  945. static PyObject *__pyx_n_s_FileWriter___init;
  946. static PyObject *__pyx_n_s_FileWriter_append;
  947. static PyObject *__pyx_n_s_FileWriter_append_utf8;
  948. static PyObject *__pyx_n_s_FileWriter_gzip;
  949. static PyObject *__pyx_n_s_FileWriter_safe_write;
  950. static PyObject *__pyx_n_s_FileWriter_safe_write_bin;
  951. static PyObject *__pyx_n_s_FileWriter_write;
  952. static PyObject *__pyx_n_s_FileWriter_write_as;
  953. static PyObject *__pyx_n_s_FileWriter_write_bin;
  954. static PyObject *__pyx_n_s_FileWriter_write_utf8;
  955. static PyObject *__pyx_n_s_IO;
  956. static PyObject *__pyx_n_s_IOError;
  957. static PyObject *__pyx_n_s_IO___init;
  958. static PyObject *__pyx_n_s_NFKD;
  959. static PyObject *__pyx_kp_s_Naked_Framework_Error_Unable_to;
  960. static PyObject *__pyx_kp_s_Naked_Framework_Error_Unable_to_10;
  961. static PyObject *__pyx_kp_s_Naked_Framework_Error_Unable_to_11;
  962. static PyObject *__pyx_kp_s_Naked_Framework_Error_Unable_to_12;
  963. static PyObject *__pyx_kp_s_Naked_Framework_Error_Unable_to_13;
  964. static PyObject *__pyx_kp_s_Naked_Framework_Error_Unable_to_14;
  965. static PyObject *__pyx_kp_s_Naked_Framework_Error_Unable_to_15;
  966. static PyObject *__pyx_kp_s_Naked_Framework_Error_Unable_to_2;
  967. static PyObject *__pyx_kp_s_Naked_Framework_Error_Unable_to_3;
  968. static PyObject *__pyx_kp_s_Naked_Framework_Error_Unable_to_4;
  969. static PyObject *__pyx_kp_s_Naked_Framework_Error_Unable_to_5;
  970. static PyObject *__pyx_kp_s_Naked_Framework_Error_Unable_to_6;
  971. static PyObject *__pyx_kp_s_Naked_Framework_Error_Unable_to_7;
  972. static PyObject *__pyx_kp_s_Naked_Framework_Error_Unable_to_8;
  973. static PyObject *__pyx_kp_s_Naked_Framework_Error_Unable_to_9;
  974. static PyObject *__pyx_kp_s_Naked_Framework_Error_unable_to;
  975. static PyObject *__pyx_kp_s_Naked_Framework_Error_unable_to_2;
  976. static PyObject *__pyx_kp_s_Naked_Framework_Error_unable_to_3;
  977. static PyObject *__pyx_kp_s_Naked_Framework_Error_unable_to_4;
  978. static PyObject *__pyx_n_s_Naked_settings;
  979. static PyObject *__pyx_n_s_Naked_toolshed_system;
  980. static PyObject *__pyx_n_s_RuntimeError;
  981. static PyObject *__pyx_kp_s_The_file_specified_for_the_text;
  982. static PyObject *__pyx_kp_s_The_file_specified_for_the_text_2;
  983. static PyObject *__pyx_kp_s_The_text_encoding_was_not_specif;
  984. static PyObject *__pyx_kp_s_The_text_file_encoding_was_not_s;
  985. static PyObject *__pyx_kp_s_The_text_file_encoding_was_not_s_2;
  986. static PyObject *__pyx_n_s_UTF8;
  987. static PyObject *__pyx_kp_s_UTF_8;
  988. static PyObject *__pyx_n_s_UTF_8_2;
  989. static PyObject *__pyx_n_s_UnicodeEncodeError;
  990. static PyObject *__pyx_kp_s_Users_ces_Desktop_code_naked_li;
  991. static PyObject *__pyx_kp_s__13;
  992. static PyObject *__pyx_n_s_a;
  993. static PyObject *__pyx_n_s_append;
  994. static PyObject *__pyx_n_s_append_utf8;
  995. static PyObject *__pyx_n_s_appender;
  996. static PyObject *__pyx_n_s_bin_reader;
  997. static PyObject *__pyx_n_s_bin_writer;
  998. static PyObject *__pyx_n_s_binary_data;
  999. static PyObject *__pyx_n_s_close;
  1000. static PyObject *__pyx_n_s_codecs;
  1001. static PyObject *__pyx_n_s_compression_level;
  1002. static PyObject *__pyx_n_s_compresslevel;
  1003. static PyObject *__pyx_n_s_data;
  1004. static PyObject *__pyx_n_s_data_list;
  1005. static PyObject *__pyx_n_s_debug;
  1006. static PyObject *__pyx_n_s_decode;
  1007. static PyObject *__pyx_n_s_dev_spec_encoding;
  1008. static PyObject *__pyx_n_s_doc;
  1009. static PyObject *__pyx_n_s_e;
  1010. static PyObject *__pyx_n_s_encode;
  1011. static PyObject *__pyx_n_s_encoding;
  1012. static PyObject *__pyx_n_s_endswith;
  1013. static PyObject *__pyx_n_s_enter;
  1014. static PyObject *__pyx_n_s_exists;
  1015. static PyObject *__pyx_n_s_exit;
  1016. static PyObject *__pyx_n_s_f;
  1017. static PyObject *__pyx_n_s_file_data;
  1018. static PyObject *__pyx_n_s_file_exists;
  1019. static PyObject *__pyx_n_s_filepath;
  1020. static PyObject *__pyx_kp_s_gz;
  1021. static PyObject *__pyx_n_s_gzip;
  1022. static PyObject *__pyx_n_s_gzip_reader;
  1023. static PyObject *__pyx_n_s_gzip_writer;
  1024. static PyObject *__pyx_n_s_import;
  1025. static PyObject *__pyx_n_s_init;
  1026. static PyObject *__pyx_n_s_ioe;
  1027. static PyObject *__pyx_n_s_lib_Naked_toolshed_c_file;
  1028. static PyObject *__pyx_n_s_line;
  1029. static PyObject *__pyx_n_s_main;
  1030. static PyObject *__pyx_n_s_metaclass;
  1031. static PyObject *__pyx_n_s_mode;
  1032. static PyObject *__pyx_n_s_modified_text_list;
  1033. static PyObject *__pyx_n_s_module;
  1034. static PyObject *__pyx_n_s_name;
  1035. static PyObject *__pyx_n_s_norm_data;
  1036. static PyObject *__pyx_n_s_norm_line;
  1037. static PyObject *__pyx_n_s_norm_text;
  1038. static PyObject *__pyx_n_s_normalize;
  1039. static PyObject *__pyx_n_s_open;
  1040. static PyObject *__pyx_n_s_os;
  1041. static PyObject *__pyx_n_s_os_path;
  1042. static PyObject *__pyx_n_s_path;
  1043. static PyObject *__pyx_n_s_prepare;
  1044. static PyObject *__pyx_n_s_qualname;
  1045. static PyObject *__pyx_n_s_r;
  1046. static PyObject *__pyx_n_s_rb;
  1047. static PyObject *__pyx_n_s_read;
  1048. static PyObject *__pyx_n_s_read_as;
  1049. static PyObject *__pyx_n_s_read_bin;
  1050. static PyObject *__pyx_n_s_read_gzip;
  1051. static PyObject *__pyx_n_s_read_utf8;
  1052. static PyObject *__pyx_n_s_reader;
  1053. static PyObject *__pyx_n_s_readlines;
  1054. static PyObject *__pyx_n_s_readlines_as;
  1055. static PyObject *__pyx_n_s_readlines_utf8;
  1056. static PyObject *__pyx_n_s_safe_write;
  1057. static PyObject *__pyx_n_s_safe_write_bin;
  1058. static PyObject *__pyx_n_s_self;
  1059. static PyObject *__pyx_n_s_stderr;
  1060. static PyObject *__pyx_n_s_sys;
  1061. static PyObject *__pyx_n_s_system_default;
  1062. static PyObject *__pyx_n_s_test;
  1063. static PyObject *__pyx_n_s_text;
  1064. static PyObject *__pyx_n_s_textstring;
  1065. static PyObject *__pyx_n_s_the_encoding;
  1066. static PyObject *__pyx_n_s_ue;
  1067. static PyObject *__pyx_n_s_uni_reader;
  1068. static PyObject *__pyx_n_s_unicodedata;
  1069. static PyObject *__pyx_n_s_utf8;
  1070. static PyObject *__pyx_n_s_utf_8;
  1071. static PyObject *__pyx_kp_s_utf_8_2;
  1072. static PyObject *__pyx_n_s_w;
  1073. static PyObject *__pyx_n_s_wb;
  1074. static PyObject *__pyx_n_s_write;
  1075. static PyObject *__pyx_n_s_write_as;
  1076. static PyObject *__pyx_n_s_write_bin;
  1077. static PyObject *__pyx_n_s_write_utf8;
  1078. static PyObject *__pyx_n_s_writer;
  1079. static PyObject *__pyx_n_s_wt;
  1080. static PyObject *__pyx_int_6;
  1081. static PyObject *__pyx_tuple_;
  1082. static PyObject *__pyx_tuple__2;
  1083. static PyObject *__pyx_tuple__3;
  1084. static PyObject *__pyx_tuple__4;
  1085. static PyObject *__pyx_tuple__5;
  1086. static PyObject *__pyx_tuple__6;
  1087. static PyObject *__pyx_tuple__7;
  1088. static PyObject *__pyx_tuple__8;
  1089. static PyObject *__pyx_tuple__9;
  1090. static PyObject *__pyx_tuple__10;
  1091. static PyObject *__pyx_tuple__11;
  1092. static PyObject *__pyx_tuple__12;
  1093. static PyObject *__pyx_tuple__14;
  1094. static PyObject *__pyx_tuple__15;
  1095. static PyObject *__pyx_tuple__16;
  1096. static PyObject *__pyx_tuple__17;
  1097. static PyObject *__pyx_tuple__18;
  1098. static PyObject *__pyx_tuple__19;
  1099. static PyObject *__pyx_tuple__20;
  1100. static PyObject *__pyx_tuple__21;
  1101. static PyObject *__pyx_tuple__22;
  1102. static PyObject *__pyx_tuple__23;
  1103. static PyObject *__pyx_tuple__24;
  1104. static PyObject *__pyx_tuple__25;
  1105. static PyObject *__pyx_tuple__26;
  1106. static PyObject *__pyx_tuple__27;
  1107. static PyObject *__pyx_tuple__28;
  1108. static PyObject *__pyx_tuple__29;
  1109. static PyObject *__pyx_tuple__30;
  1110. static PyObject *__pyx_tuple__31;
  1111. static PyObject *__pyx_tuple__32;
  1112. static PyObject *__pyx_tuple__33;
  1113. static PyObject *__pyx_tuple__34;
  1114. static PyObject *__pyx_tuple__35;
  1115. static PyObject *__pyx_tuple__36;
  1116. static PyObject *__pyx_tuple__37;
  1117. static PyObject *__pyx_tuple__38;
  1118. static PyObject *__pyx_tuple__39;
  1119. static PyObject *__pyx_tuple__40;
  1120. static PyObject *__pyx_tuple__41;
  1121. static PyObject *__pyx_tuple__42;
  1122. static PyObject *__pyx_tuple__43;
  1123. static PyObject *__pyx_tuple__44;
  1124. static PyObject *__pyx_tuple__45;
  1125. static PyObject *__pyx_tuple__47;
  1126. static PyObject *__pyx_tuple__49;
  1127. static PyObject *__pyx_tuple__51;
  1128. static PyObject *__pyx_tuple__53;
  1129. static PyObject *__pyx_tuple__55;
  1130. static PyObject *__pyx_tuple__56;
  1131. static PyObject *__pyx_tuple__58;
  1132. static PyObject *__pyx_tuple__60;
  1133. static PyObject *__pyx_tuple__61;
  1134. static PyObject *__pyx_tuple__63;
  1135. static PyObject *__pyx_tuple__65;
  1136. static PyObject *__pyx_tuple__67;
  1137. static PyObject *__pyx_tuple__69;
  1138. static PyObject *__pyx_tuple__71;
  1139. static PyObject *__pyx_tuple__73;
  1140. static PyObject *__pyx_tuple__75;
  1141. static PyObject *__pyx_tuple__77;
  1142. static PyObject *__pyx_tuple__79;
  1143. static PyObject *__pyx_tuple__81;
  1144. static PyObject *__pyx_tuple__83;
  1145. static PyObject *__pyx_tuple__85;
  1146. static PyObject *__pyx_tuple__86;
  1147. static PyObject *__pyx_codeobj__46;
  1148. static PyObject *__pyx_codeobj__48;
  1149. static PyObject *__pyx_codeobj__50;
  1150. static PyObject *__pyx_codeobj__52;
  1151. static PyObject *__pyx_codeobj__54;
  1152. static PyObject *__pyx_codeobj__57;
  1153. static PyObject *__pyx_codeobj__59;
  1154. static PyObject *__pyx_codeobj__62;
  1155. static PyObject *__pyx_codeobj__64;
  1156. static PyObject *__pyx_codeobj__66;
  1157. static PyObject *__pyx_codeobj__68;
  1158. static PyObject *__pyx_codeobj__70;
  1159. static PyObject *__pyx_codeobj__72;
  1160. static PyObject *__pyx_codeobj__74;
  1161. static PyObject *__pyx_codeobj__76;
  1162. static PyObject *__pyx_codeobj__78;
  1163. static PyObject *__pyx_codeobj__80;
  1164. static PyObject *__pyx_codeobj__82;
  1165. static PyObject *__pyx_codeobj__84;
  1166. static PyObject *__pyx_codeobj__87;
  1167. /* "lib/Naked/toolshed/c/file.pyx":13
  1168. * #------------------------------------------------------------------------------
  1169. * class IO:
  1170. * def __init__(self,filepath): # <<<<<<<<<<<<<<
  1171. * self.filepath = filepath
  1172. *
  1173. */
  1174. /* Python wrapper */
  1175. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_2IO_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1176. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_2IO_1__init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_2IO_1__init__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  1177. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_2IO_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  1178. PyObject *__pyx_v_self = 0;
  1179. PyObject *__pyx_v_filepath = 0;
  1180. int __pyx_lineno = 0;
  1181. const char *__pyx_filename = NULL;
  1182. int __pyx_clineno = 0;
  1183. PyObject *__pyx_r = 0;
  1184. __Pyx_RefNannyDeclarations
  1185. __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  1186. {
  1187. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_filepath,0};
  1188. PyObject* values[2] = {0,0};
  1189. if (unlikely(__pyx_kwds)) {
  1190. Py_ssize_t kw_args;
  1191. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  1192. switch (pos_args) {
  1193. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1194. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1195. case 0: break;
  1196. default: goto __pyx_L5_argtuple_error;
  1197. }
  1198. kw_args = PyDict_Size(__pyx_kwds);
  1199. switch (pos_args) {
  1200. case 0:
  1201. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
  1202. else goto __pyx_L5_argtuple_error;
  1203. case 1:
  1204. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filepath)) != 0)) kw_args--;
  1205. else {
  1206. __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1207. }
  1208. }
  1209. if (unlikely(kw_args > 0)) {
  1210. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1211. }
  1212. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  1213. goto __pyx_L5_argtuple_error;
  1214. } else {
  1215. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1216. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1217. }
  1218. __pyx_v_self = values[0];
  1219. __pyx_v_filepath = values[1];
  1220. }
  1221. goto __pyx_L4_argument_unpacking_done;
  1222. __pyx_L5_argtuple_error:;
  1223. __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1224. __pyx_L3_error:;
  1225. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.IO.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1226. __Pyx_RefNannyFinishContext();
  1227. return NULL;
  1228. __pyx_L4_argument_unpacking_done:;
  1229. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_2IO___init__(__pyx_self, __pyx_v_self, __pyx_v_filepath);
  1230. /* function exit code */
  1231. __Pyx_RefNannyFinishContext();
  1232. return __pyx_r;
  1233. }
  1234. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_2IO___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_filepath) {
  1235. PyObject *__pyx_r = NULL;
  1236. __Pyx_RefNannyDeclarations
  1237. int __pyx_lineno = 0;
  1238. const char *__pyx_filename = NULL;
  1239. int __pyx_clineno = 0;
  1240. __Pyx_RefNannySetupContext("__init__", 0);
  1241. /* "lib/Naked/toolshed/c/file.pyx":14
  1242. * class IO:
  1243. * def __init__(self,filepath):
  1244. * self.filepath = filepath # <<<<<<<<<<<<<<
  1245. *
  1246. * #------------------------------------------------------------------------------
  1247. */
  1248. if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_filepath, __pyx_v_filepath) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1249. /* "lib/Naked/toolshed/c/file.pyx":13
  1250. * #------------------------------------------------------------------------------
  1251. * class IO:
  1252. * def __init__(self,filepath): # <<<<<<<<<<<<<<
  1253. * self.filepath = filepath
  1254. *
  1255. */
  1256. /* function exit code */
  1257. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  1258. goto __pyx_L0;
  1259. __pyx_L1_error:;
  1260. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.IO.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1261. __pyx_r = NULL;
  1262. __pyx_L0:;
  1263. __Pyx_XGIVEREF(__pyx_r);
  1264. __Pyx_RefNannyFinishContext();
  1265. return __pyx_r;
  1266. }
  1267. /* "lib/Naked/toolshed/c/file.pyx":21
  1268. * #------------------------------------------------------------------------------
  1269. * class FileWriter(IO):
  1270. * def __init__(self, filepath): # <<<<<<<<<<<<<<
  1271. * IO.__init__(self, filepath)
  1272. *
  1273. */
  1274. /* Python wrapper */
  1275. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1276. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_1__init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_1__init__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  1277. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  1278. PyObject *__pyx_v_self = 0;
  1279. PyObject *__pyx_v_filepath = 0;
  1280. int __pyx_lineno = 0;
  1281. const char *__pyx_filename = NULL;
  1282. int __pyx_clineno = 0;
  1283. PyObject *__pyx_r = 0;
  1284. __Pyx_RefNannyDeclarations
  1285. __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  1286. {
  1287. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_filepath,0};
  1288. PyObject* values[2] = {0,0};
  1289. if (unlikely(__pyx_kwds)) {
  1290. Py_ssize_t kw_args;
  1291. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  1292. switch (pos_args) {
  1293. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1294. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1295. case 0: break;
  1296. default: goto __pyx_L5_argtuple_error;
  1297. }
  1298. kw_args = PyDict_Size(__pyx_kwds);
  1299. switch (pos_args) {
  1300. case 0:
  1301. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
  1302. else goto __pyx_L5_argtuple_error;
  1303. case 1:
  1304. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filepath)) != 0)) kw_args--;
  1305. else {
  1306. __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1307. }
  1308. }
  1309. if (unlikely(kw_args > 0)) {
  1310. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1311. }
  1312. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  1313. goto __pyx_L5_argtuple_error;
  1314. } else {
  1315. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1316. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1317. }
  1318. __pyx_v_self = values[0];
  1319. __pyx_v_filepath = values[1];
  1320. }
  1321. goto __pyx_L4_argument_unpacking_done;
  1322. __pyx_L5_argtuple_error:;
  1323. __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1324. __pyx_L3_error:;
  1325. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1326. __Pyx_RefNannyFinishContext();
  1327. return NULL;
  1328. __pyx_L4_argument_unpacking_done:;
  1329. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter___init__(__pyx_self, __pyx_v_self, __pyx_v_filepath);
  1330. /* function exit code */
  1331. __Pyx_RefNannyFinishContext();
  1332. return __pyx_r;
  1333. }
  1334. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_filepath) {
  1335. PyObject *__pyx_r = NULL;
  1336. __Pyx_RefNannyDeclarations
  1337. PyObject *__pyx_t_1 = NULL;
  1338. PyObject *__pyx_t_2 = NULL;
  1339. PyObject *__pyx_t_3 = NULL;
  1340. int __pyx_lineno = 0;
  1341. const char *__pyx_filename = NULL;
  1342. int __pyx_clineno = 0;
  1343. __Pyx_RefNannySetupContext("__init__", 0);
  1344. /* "lib/Naked/toolshed/c/file.pyx":22
  1345. * class FileWriter(IO):
  1346. * def __init__(self, filepath):
  1347. * IO.__init__(self, filepath) # <<<<<<<<<<<<<<
  1348. *
  1349. * #------------------------------------------------------------------------------
  1350. */
  1351. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_IO); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1352. __Pyx_GOTREF(__pyx_t_1);
  1353. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1354. __Pyx_GOTREF(__pyx_t_2);
  1355. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1356. __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1357. __Pyx_GOTREF(__pyx_t_1);
  1358. __Pyx_INCREF(__pyx_v_self);
  1359. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
  1360. __Pyx_GIVEREF(__pyx_v_self);
  1361. __Pyx_INCREF(__pyx_v_filepath);
  1362. PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_filepath);
  1363. __Pyx_GIVEREF(__pyx_v_filepath);
  1364. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1365. __Pyx_GOTREF(__pyx_t_3);
  1366. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1367. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1368. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  1369. /* "lib/Naked/toolshed/c/file.pyx":21
  1370. * #------------------------------------------------------------------------------
  1371. * class FileWriter(IO):
  1372. * def __init__(self, filepath): # <<<<<<<<<<<<<<
  1373. * IO.__init__(self, filepath)
  1374. *
  1375. */
  1376. /* function exit code */
  1377. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  1378. goto __pyx_L0;
  1379. __pyx_L1_error:;
  1380. __Pyx_XDECREF(__pyx_t_1);
  1381. __Pyx_XDECREF(__pyx_t_2);
  1382. __Pyx_XDECREF(__pyx_t_3);
  1383. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1384. __pyx_r = NULL;
  1385. __pyx_L0:;
  1386. __Pyx_XGIVEREF(__pyx_r);
  1387. __Pyx_RefNannyFinishContext();
  1388. return __pyx_r;
  1389. }
  1390. /* "lib/Naked/toolshed/c/file.pyx":29
  1391. * # Tests: test_IO.py:: test_file_ascii_readwrite_append, test_file_append_missingfile
  1392. * #------------------------------------------------------------------------------
  1393. * def append(self, text): # <<<<<<<<<<<<<<
  1394. * try:
  1395. * from Naked.toolshed.system import file_exists
  1396. */
  1397. /* Python wrapper */
  1398. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_3append(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1399. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_3append = {__Pyx_NAMESTR("append"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_3append, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  1400. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_3append(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  1401. PyObject *__pyx_v_self = 0;
  1402. PyObject *__pyx_v_text = 0;
  1403. int __pyx_lineno = 0;
  1404. const char *__pyx_filename = NULL;
  1405. int __pyx_clineno = 0;
  1406. PyObject *__pyx_r = 0;
  1407. __Pyx_RefNannyDeclarations
  1408. __Pyx_RefNannySetupContext("append (wrapper)", 0);
  1409. {
  1410. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_text,0};
  1411. PyObject* values[2] = {0,0};
  1412. if (unlikely(__pyx_kwds)) {
  1413. Py_ssize_t kw_args;
  1414. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  1415. switch (pos_args) {
  1416. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1417. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1418. case 0: break;
  1419. default: goto __pyx_L5_argtuple_error;
  1420. }
  1421. kw_args = PyDict_Size(__pyx_kwds);
  1422. switch (pos_args) {
  1423. case 0:
  1424. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
  1425. else goto __pyx_L5_argtuple_error;
  1426. case 1:
  1427. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_text)) != 0)) kw_args--;
  1428. else {
  1429. __Pyx_RaiseArgtupleInvalid("append", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1430. }
  1431. }
  1432. if (unlikely(kw_args > 0)) {
  1433. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "append") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1434. }
  1435. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  1436. goto __pyx_L5_argtuple_error;
  1437. } else {
  1438. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1439. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1440. }
  1441. __pyx_v_self = values[0];
  1442. __pyx_v_text = values[1];
  1443. }
  1444. goto __pyx_L4_argument_unpacking_done;
  1445. __pyx_L5_argtuple_error:;
  1446. __Pyx_RaiseArgtupleInvalid("append", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1447. __pyx_L3_error:;
  1448. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1449. __Pyx_RefNannyFinishContext();
  1450. return NULL;
  1451. __pyx_L4_argument_unpacking_done:;
  1452. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_2append(__pyx_self, __pyx_v_self, __pyx_v_text);
  1453. /* function exit code */
  1454. __Pyx_RefNannyFinishContext();
  1455. return __pyx_r;
  1456. }
  1457. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_2append(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_text) {
  1458. PyObject *__pyx_v_file_exists = NULL;
  1459. PyObject *__pyx_v_appender = NULL;
  1460. CYTHON_UNUSED PyObject *__pyx_v_ue = NULL;
  1461. PyObject *__pyx_v_e = NULL;
  1462. PyObject *__pyx_r = NULL;
  1463. __Pyx_RefNannyDeclarations
  1464. PyObject *__pyx_t_1 = NULL;
  1465. PyObject *__pyx_t_2 = NULL;
  1466. PyObject *__pyx_t_3 = NULL;
  1467. PyObject *__pyx_t_4 = NULL;
  1468. PyObject *__pyx_t_5 = NULL;
  1469. int __pyx_t_6;
  1470. int __pyx_t_7;
  1471. PyObject *__pyx_t_8 = NULL;
  1472. PyObject *__pyx_t_9 = NULL;
  1473. PyObject *__pyx_t_10 = NULL;
  1474. PyObject *__pyx_t_11 = NULL;
  1475. PyObject *__pyx_t_12 = NULL;
  1476. PyObject *__pyx_t_13 = NULL;
  1477. PyObject *__pyx_t_14 = NULL;
  1478. int __pyx_t_15;
  1479. PyObject *__pyx_t_16 = NULL;
  1480. PyObject *__pyx_t_17 = NULL;
  1481. int __pyx_lineno = 0;
  1482. const char *__pyx_filename = NULL;
  1483. int __pyx_clineno = 0;
  1484. __Pyx_RefNannySetupContext("append", 0);
  1485. /* "lib/Naked/toolshed/c/file.pyx":30
  1486. * #------------------------------------------------------------------------------
  1487. * def append(self, text):
  1488. * try: # <<<<<<<<<<<<<<
  1489. * from Naked.toolshed.system import file_exists
  1490. * if not file_exists(self.filepath): #confirm that file exists, if not raise IOError (assuming that developer expected existing file if using append)
  1491. */
  1492. {
  1493. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  1494. __Pyx_XGOTREF(__pyx_t_1);
  1495. __Pyx_XGOTREF(__pyx_t_2);
  1496. __Pyx_XGOTREF(__pyx_t_3);
  1497. /*try:*/ {
  1498. /* "lib/Naked/toolshed/c/file.pyx":31
  1499. * def append(self, text):
  1500. * try:
  1501. * from Naked.toolshed.system import file_exists # <<<<<<<<<<<<<<
  1502. * if not file_exists(self.filepath): #confirm that file exists, if not raise IOError (assuming that developer expected existing file if using append)
  1503. * raise IOError("The file specified for the text append does not exist (Naked.toolshed.file.py:append).")
  1504. */
  1505. __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1506. __Pyx_GOTREF(__pyx_t_4);
  1507. __Pyx_INCREF(__pyx_n_s_file_exists);
  1508. PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_file_exists);
  1509. __Pyx_GIVEREF(__pyx_n_s_file_exists);
  1510. __pyx_t_5 = __Pyx_Import(__pyx_n_s_Naked_toolshed_system, __pyx_t_4, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1511. __Pyx_GOTREF(__pyx_t_5);
  1512. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1513. __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_file_exists); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1514. __Pyx_GOTREF(__pyx_t_4);
  1515. __Pyx_INCREF(__pyx_t_4);
  1516. __pyx_v_file_exists = __pyx_t_4;
  1517. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1518. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1519. /* "lib/Naked/toolshed/c/file.pyx":32
  1520. * try:
  1521. * from Naked.toolshed.system import file_exists
  1522. * if not file_exists(self.filepath): #confirm that file exists, if not raise IOError (assuming that developer expected existing file if using append) # <<<<<<<<<<<<<<
  1523. * raise IOError("The file specified for the text append does not exist (Naked.toolshed.file.py:append).")
  1524. * with open(self.filepath, 'a') as appender:
  1525. */
  1526. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1527. __Pyx_GOTREF(__pyx_t_5);
  1528. __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1529. __Pyx_GOTREF(__pyx_t_4);
  1530. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
  1531. __Pyx_GIVEREF(__pyx_t_5);
  1532. __pyx_t_5 = 0;
  1533. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_v_file_exists, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1534. __Pyx_GOTREF(__pyx_t_5);
  1535. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1536. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1537. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1538. __pyx_t_7 = ((!__pyx_t_6) != 0);
  1539. if (__pyx_t_7) {
  1540. /* "lib/Naked/toolshed/c/file.pyx":33
  1541. * from Naked.toolshed.system import file_exists
  1542. * if not file_exists(self.filepath): #confirm that file exists, if not raise IOError (assuming that developer expected existing file if using append)
  1543. * raise IOError("The file specified for the text append does not exist (Naked.toolshed.file.py:append).") # <<<<<<<<<<<<<<
  1544. * with open(self.filepath, 'a') as appender:
  1545. * appender.write(text)
  1546. */
  1547. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1548. __Pyx_GOTREF(__pyx_t_5);
  1549. __Pyx_Raise(__pyx_t_5, 0, 0, 0);
  1550. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1551. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1552. }
  1553. /* "lib/Naked/toolshed/c/file.pyx":34
  1554. * if not file_exists(self.filepath): #confirm that file exists, if not raise IOError (assuming that developer expected existing file if using append)
  1555. * raise IOError("The file specified for the text append does not exist (Naked.toolshed.file.py:append).")
  1556. * with open(self.filepath, 'a') as appender: # <<<<<<<<<<<<<<
  1557. * appender.write(text)
  1558. * except UnicodeEncodeError as ue:
  1559. */
  1560. /*with:*/ {
  1561. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1562. __Pyx_GOTREF(__pyx_t_5);
  1563. __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1564. __Pyx_GOTREF(__pyx_t_4);
  1565. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
  1566. __Pyx_GIVEREF(__pyx_t_5);
  1567. __Pyx_INCREF(__pyx_n_s_a);
  1568. PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_a);
  1569. __Pyx_GIVEREF(__pyx_n_s_a);
  1570. __pyx_t_5 = 0;
  1571. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1572. __Pyx_GOTREF(__pyx_t_5);
  1573. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1574. __pyx_t_8 = __Pyx_PyObject_LookupSpecial(__pyx_t_5, __pyx_n_s_exit); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1575. __Pyx_GOTREF(__pyx_t_8);
  1576. __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_5, __pyx_n_s_enter); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
  1577. __Pyx_GOTREF(__pyx_t_4);
  1578. __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
  1579. __Pyx_GOTREF(__pyx_t_9);
  1580. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1581. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1582. /*try:*/ {
  1583. {
  1584. __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
  1585. __Pyx_XGOTREF(__pyx_t_10);
  1586. __Pyx_XGOTREF(__pyx_t_11);
  1587. __Pyx_XGOTREF(__pyx_t_12);
  1588. /*try:*/ {
  1589. __Pyx_INCREF(__pyx_t_9);
  1590. __pyx_v_appender = __pyx_t_9;
  1591. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  1592. /* "lib/Naked/toolshed/c/file.pyx":35
  1593. * raise IOError("The file specified for the text append does not exist (Naked.toolshed.file.py:append).")
  1594. * with open(self.filepath, 'a') as appender:
  1595. * appender.write(text) # <<<<<<<<<<<<<<
  1596. * except UnicodeEncodeError as ue:
  1597. * self.append_utf8(text) #try writing as utf-8
  1598. */
  1599. __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_appender, __pyx_n_s_write); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  1600. __Pyx_GOTREF(__pyx_t_9);
  1601. __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  1602. __Pyx_GOTREF(__pyx_t_5);
  1603. __Pyx_INCREF(__pyx_v_text);
  1604. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_text);
  1605. __Pyx_GIVEREF(__pyx_v_text);
  1606. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  1607. __Pyx_GOTREF(__pyx_t_4);
  1608. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  1609. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1610. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1611. }
  1612. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  1613. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  1614. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  1615. goto __pyx_L25_try_end;
  1616. __pyx_L18_error:;
  1617. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  1618. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  1619. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  1620. /* "lib/Naked/toolshed/c/file.pyx":34
  1621. * if not file_exists(self.filepath): #confirm that file exists, if not raise IOError (assuming that developer expected existing file if using append)
  1622. * raise IOError("The file specified for the text append does not exist (Naked.toolshed.file.py:append).")
  1623. * with open(self.filepath, 'a') as appender: # <<<<<<<<<<<<<<
  1624. * appender.write(text)
  1625. * except UnicodeEncodeError as ue:
  1626. */
  1627. /*except:*/ {
  1628. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1629. if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  1630. __Pyx_GOTREF(__pyx_t_4);
  1631. __Pyx_GOTREF(__pyx_t_5);
  1632. __Pyx_GOTREF(__pyx_t_9);
  1633. __pyx_t_13 = PyTuple_Pack(3, __pyx_t_4, __pyx_t_5, __pyx_t_9); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  1634. __Pyx_GOTREF(__pyx_t_13);
  1635. __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_13, NULL);
  1636. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1637. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  1638. if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  1639. __Pyx_GOTREF(__pyx_t_14);
  1640. __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_14);
  1641. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  1642. if (__pyx_t_7 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  1643. __pyx_t_6 = ((!(__pyx_t_7 != 0)) != 0);
  1644. if (__pyx_t_6) {
  1645. __Pyx_GIVEREF(__pyx_t_4);
  1646. __Pyx_GIVEREF(__pyx_t_5);
  1647. __Pyx_XGIVEREF(__pyx_t_9);
  1648. __Pyx_ErrRestore(__pyx_t_4, __pyx_t_5, __pyx_t_9);
  1649. __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_9 = 0;
  1650. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  1651. }
  1652. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1653. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1654. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  1655. goto __pyx_L19_exception_handled;
  1656. }
  1657. __pyx_L20_except_error:;
  1658. __Pyx_XGIVEREF(__pyx_t_10);
  1659. __Pyx_XGIVEREF(__pyx_t_11);
  1660. __Pyx_XGIVEREF(__pyx_t_12);
  1661. __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
  1662. goto __pyx_L3_error;
  1663. __pyx_L19_exception_handled:;
  1664. __Pyx_XGIVEREF(__pyx_t_10);
  1665. __Pyx_XGIVEREF(__pyx_t_11);
  1666. __Pyx_XGIVEREF(__pyx_t_12);
  1667. __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
  1668. __pyx_L25_try_end:;
  1669. }
  1670. }
  1671. /*finally:*/ {
  1672. /*normal exit:*/{
  1673. if (__pyx_t_8) {
  1674. __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__2, NULL);
  1675. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1676. if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1677. __Pyx_GOTREF(__pyx_t_12);
  1678. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  1679. }
  1680. goto __pyx_L17;
  1681. }
  1682. __pyx_L17:;
  1683. }
  1684. goto __pyx_L30;
  1685. __pyx_L12_error:;
  1686. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1687. goto __pyx_L3_error;
  1688. __pyx_L30:;
  1689. }
  1690. }
  1691. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  1692. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  1693. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  1694. goto __pyx_L10_try_end;
  1695. __pyx_L3_error:;
  1696. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  1697. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  1698. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  1699. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  1700. /* "lib/Naked/toolshed/c/file.pyx":36
  1701. * with open(self.filepath, 'a') as appender:
  1702. * appender.write(text)
  1703. * except UnicodeEncodeError as ue: # <<<<<<<<<<<<<<
  1704. * self.append_utf8(text) #try writing as utf-8
  1705. * except Exception as e:
  1706. */
  1707. __pyx_t_15 = PyErr_ExceptionMatches(__pyx_builtin_UnicodeEncodeError);
  1708. if (__pyx_t_15) {
  1709. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1710. if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_5, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1711. __Pyx_GOTREF(__pyx_t_9);
  1712. __Pyx_GOTREF(__pyx_t_5);
  1713. __Pyx_GOTREF(__pyx_t_4);
  1714. __Pyx_INCREF(__pyx_t_5);
  1715. __pyx_v_ue = __pyx_t_5;
  1716. /* "lib/Naked/toolshed/c/file.pyx":37
  1717. * appender.write(text)
  1718. * except UnicodeEncodeError as ue:
  1719. * self.append_utf8(text) #try writing as utf-8 # <<<<<<<<<<<<<<
  1720. * except Exception as e:
  1721. * if DEBUG_FLAG:
  1722. */
  1723. __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_append_utf8); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1724. __Pyx_GOTREF(__pyx_t_13);
  1725. __pyx_t_16 = PyTuple_New(1); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1726. __Pyx_GOTREF(__pyx_t_16);
  1727. __Pyx_INCREF(__pyx_v_text);
  1728. PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_v_text);
  1729. __Pyx_GIVEREF(__pyx_v_text);
  1730. __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_16, NULL); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1731. __Pyx_GOTREF(__pyx_t_17);
  1732. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  1733. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  1734. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  1735. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  1736. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1737. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1738. goto __pyx_L4_exception_handled;
  1739. }
  1740. /* "lib/Naked/toolshed/c/file.pyx":38
  1741. * except UnicodeEncodeError as ue:
  1742. * self.append_utf8(text) #try writing as utf-8
  1743. * except Exception as e: # <<<<<<<<<<<<<<
  1744. * if DEBUG_FLAG:
  1745. * sys.stderr.write("Naked Framework Error: Unable to append text to the file with the append() method (Naked.toolshed.file.py).")
  1746. */
  1747. __pyx_t_15 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  1748. if (__pyx_t_15) {
  1749. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1750. if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1751. __Pyx_GOTREF(__pyx_t_4);
  1752. __Pyx_GOTREF(__pyx_t_5);
  1753. __Pyx_GOTREF(__pyx_t_9);
  1754. __Pyx_INCREF(__pyx_t_5);
  1755. __pyx_v_e = __pyx_t_5;
  1756. /* "lib/Naked/toolshed/c/file.pyx":39
  1757. * self.append_utf8(text) #try writing as utf-8
  1758. * except Exception as e:
  1759. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  1760. * sys.stderr.write("Naked Framework Error: Unable to append text to the file with the append() method (Naked.toolshed.file.py).")
  1761. * raise e
  1762. */
  1763. __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1764. __Pyx_GOTREF(__pyx_t_17);
  1765. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_17); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1766. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  1767. if (__pyx_t_6) {
  1768. /* "lib/Naked/toolshed/c/file.pyx":40
  1769. * except Exception as e:
  1770. * if DEBUG_FLAG:
  1771. * sys.stderr.write("Naked Framework Error: Unable to append text to the file with the append() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  1772. * raise e
  1773. *
  1774. */
  1775. __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1776. __Pyx_GOTREF(__pyx_t_17);
  1777. __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_stderr); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1778. __Pyx_GOTREF(__pyx_t_16);
  1779. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  1780. __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_write); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1781. __Pyx_GOTREF(__pyx_t_17);
  1782. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  1783. __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1784. __Pyx_GOTREF(__pyx_t_16);
  1785. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  1786. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  1787. goto __pyx_L35;
  1788. }
  1789. __pyx_L35:;
  1790. /* "lib/Naked/toolshed/c/file.pyx":41
  1791. * if DEBUG_FLAG:
  1792. * sys.stderr.write("Naked Framework Error: Unable to append text to the file with the append() method (Naked.toolshed.file.py).")
  1793. * raise e # <<<<<<<<<<<<<<
  1794. *
  1795. * #------------------------------------------------------------------------------
  1796. */
  1797. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  1798. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1799. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1800. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1801. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  1802. goto __pyx_L4_exception_handled;
  1803. }
  1804. goto __pyx_L5_except_error;
  1805. __pyx_L5_except_error:;
  1806. __Pyx_XGIVEREF(__pyx_t_1);
  1807. __Pyx_XGIVEREF(__pyx_t_2);
  1808. __Pyx_XGIVEREF(__pyx_t_3);
  1809. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  1810. goto __pyx_L1_error;
  1811. __pyx_L4_exception_handled:;
  1812. __Pyx_XGIVEREF(__pyx_t_1);
  1813. __Pyx_XGIVEREF(__pyx_t_2);
  1814. __Pyx_XGIVEREF(__pyx_t_3);
  1815. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  1816. __pyx_L10_try_end:;
  1817. }
  1818. /* "lib/Naked/toolshed/c/file.pyx":29
  1819. * # Tests: test_IO.py:: test_file_ascii_readwrite_append, test_file_append_missingfile
  1820. * #------------------------------------------------------------------------------
  1821. * def append(self, text): # <<<<<<<<<<<<<<
  1822. * try:
  1823. * from Naked.toolshed.system import file_exists
  1824. */
  1825. /* function exit code */
  1826. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  1827. goto __pyx_L0;
  1828. __pyx_L1_error:;
  1829. __Pyx_XDECREF(__pyx_t_4);
  1830. __Pyx_XDECREF(__pyx_t_5);
  1831. __Pyx_XDECREF(__pyx_t_9);
  1832. __Pyx_XDECREF(__pyx_t_13);
  1833. __Pyx_XDECREF(__pyx_t_16);
  1834. __Pyx_XDECREF(__pyx_t_17);
  1835. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.append", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1836. __pyx_r = NULL;
  1837. __pyx_L0:;
  1838. __Pyx_XDECREF(__pyx_v_file_exists);
  1839. __Pyx_XDECREF(__pyx_v_appender);
  1840. __Pyx_XDECREF(__pyx_v_ue);
  1841. __Pyx_XDECREF(__pyx_v_e);
  1842. __Pyx_XGIVEREF(__pyx_r);
  1843. __Pyx_RefNannyFinishContext();
  1844. return __pyx_r;
  1845. }
  1846. /* "lib/Naked/toolshed/c/file.pyx":48
  1847. * # Tests: test_IO.py :: test_file_utf8_readwrite_append
  1848. * #------------------------------------------------------------------------------
  1849. * def append_utf8(self, text): # <<<<<<<<<<<<<<
  1850. * try:
  1851. * from Naked.toolshed.system import file_exists
  1852. */
  1853. /* Python wrapper */
  1854. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_5append_utf8(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1855. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_5append_utf8 = {__Pyx_NAMESTR("append_utf8"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_5append_utf8, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  1856. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_5append_utf8(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  1857. PyObject *__pyx_v_self = 0;
  1858. PyObject *__pyx_v_text = 0;
  1859. int __pyx_lineno = 0;
  1860. const char *__pyx_filename = NULL;
  1861. int __pyx_clineno = 0;
  1862. PyObject *__pyx_r = 0;
  1863. __Pyx_RefNannyDeclarations
  1864. __Pyx_RefNannySetupContext("append_utf8 (wrapper)", 0);
  1865. {
  1866. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_text,0};
  1867. PyObject* values[2] = {0,0};
  1868. if (unlikely(__pyx_kwds)) {
  1869. Py_ssize_t kw_args;
  1870. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  1871. switch (pos_args) {
  1872. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1873. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1874. case 0: break;
  1875. default: goto __pyx_L5_argtuple_error;
  1876. }
  1877. kw_args = PyDict_Size(__pyx_kwds);
  1878. switch (pos_args) {
  1879. case 0:
  1880. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
  1881. else goto __pyx_L5_argtuple_error;
  1882. case 1:
  1883. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_text)) != 0)) kw_args--;
  1884. else {
  1885. __Pyx_RaiseArgtupleInvalid("append_utf8", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1886. }
  1887. }
  1888. if (unlikely(kw_args > 0)) {
  1889. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "append_utf8") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1890. }
  1891. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  1892. goto __pyx_L5_argtuple_error;
  1893. } else {
  1894. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1895. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1896. }
  1897. __pyx_v_self = values[0];
  1898. __pyx_v_text = values[1];
  1899. }
  1900. goto __pyx_L4_argument_unpacking_done;
  1901. __pyx_L5_argtuple_error:;
  1902. __Pyx_RaiseArgtupleInvalid("append_utf8", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1903. __pyx_L3_error:;
  1904. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.append_utf8", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1905. __Pyx_RefNannyFinishContext();
  1906. return NULL;
  1907. __pyx_L4_argument_unpacking_done:;
  1908. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_4append_utf8(__pyx_self, __pyx_v_self, __pyx_v_text);
  1909. /* function exit code */
  1910. __Pyx_RefNannyFinishContext();
  1911. return __pyx_r;
  1912. }
  1913. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_4append_utf8(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_text) {
  1914. PyObject *__pyx_v_file_exists = NULL;
  1915. PyObject *__pyx_v_codecs = NULL;
  1916. PyObject *__pyx_v_unicodedata = NULL;
  1917. PyObject *__pyx_v_norm_text = NULL;
  1918. PyObject *__pyx_v_appender = NULL;
  1919. PyObject *__pyx_v_e = NULL;
  1920. PyObject *__pyx_r = NULL;
  1921. __Pyx_RefNannyDeclarations
  1922. PyObject *__pyx_t_1 = NULL;
  1923. PyObject *__pyx_t_2 = NULL;
  1924. PyObject *__pyx_t_3 = NULL;
  1925. PyObject *__pyx_t_4 = NULL;
  1926. PyObject *__pyx_t_5 = NULL;
  1927. int __pyx_t_6;
  1928. int __pyx_t_7;
  1929. PyObject *__pyx_t_8 = NULL;
  1930. PyObject *__pyx_t_9 = NULL;
  1931. PyObject *__pyx_t_10 = NULL;
  1932. PyObject *__pyx_t_11 = NULL;
  1933. PyObject *__pyx_t_12 = NULL;
  1934. PyObject *__pyx_t_13 = NULL;
  1935. PyObject *__pyx_t_14 = NULL;
  1936. int __pyx_t_15;
  1937. PyObject *__pyx_t_16 = NULL;
  1938. int __pyx_lineno = 0;
  1939. const char *__pyx_filename = NULL;
  1940. int __pyx_clineno = 0;
  1941. __Pyx_RefNannySetupContext("append_utf8", 0);
  1942. /* "lib/Naked/toolshed/c/file.pyx":49
  1943. * #------------------------------------------------------------------------------
  1944. * def append_utf8(self, text):
  1945. * try: # <<<<<<<<<<<<<<
  1946. * from Naked.toolshed.system import file_exists
  1947. * if not file_exists(self.filepath):
  1948. */
  1949. {
  1950. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  1951. __Pyx_XGOTREF(__pyx_t_1);
  1952. __Pyx_XGOTREF(__pyx_t_2);
  1953. __Pyx_XGOTREF(__pyx_t_3);
  1954. /*try:*/ {
  1955. /* "lib/Naked/toolshed/c/file.pyx":50
  1956. * def append_utf8(self, text):
  1957. * try:
  1958. * from Naked.toolshed.system import file_exists # <<<<<<<<<<<<<<
  1959. * if not file_exists(self.filepath):
  1960. * raise IOError("The file specified for the text append does not exist (Naked.toolshed.file.py:append_utf8).")
  1961. */
  1962. __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1963. __Pyx_GOTREF(__pyx_t_4);
  1964. __Pyx_INCREF(__pyx_n_s_file_exists);
  1965. PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_file_exists);
  1966. __Pyx_GIVEREF(__pyx_n_s_file_exists);
  1967. __pyx_t_5 = __Pyx_Import(__pyx_n_s_Naked_toolshed_system, __pyx_t_4, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1968. __Pyx_GOTREF(__pyx_t_5);
  1969. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1970. __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_file_exists); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1971. __Pyx_GOTREF(__pyx_t_4);
  1972. __Pyx_INCREF(__pyx_t_4);
  1973. __pyx_v_file_exists = __pyx_t_4;
  1974. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1975. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1976. /* "lib/Naked/toolshed/c/file.pyx":51
  1977. * try:
  1978. * from Naked.toolshed.system import file_exists
  1979. * if not file_exists(self.filepath): # <<<<<<<<<<<<<<
  1980. * raise IOError("The file specified for the text append does not exist (Naked.toolshed.file.py:append_utf8).")
  1981. * import codecs
  1982. */
  1983. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1984. __Pyx_GOTREF(__pyx_t_5);
  1985. __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1986. __Pyx_GOTREF(__pyx_t_4);
  1987. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
  1988. __Pyx_GIVEREF(__pyx_t_5);
  1989. __pyx_t_5 = 0;
  1990. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_v_file_exists, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1991. __Pyx_GOTREF(__pyx_t_5);
  1992. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1993. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1994. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1995. __pyx_t_7 = ((!__pyx_t_6) != 0);
  1996. if (__pyx_t_7) {
  1997. /* "lib/Naked/toolshed/c/file.pyx":52
  1998. * from Naked.toolshed.system import file_exists
  1999. * if not file_exists(self.filepath):
  2000. * raise IOError("The file specified for the text append does not exist (Naked.toolshed.file.py:append_utf8).") # <<<<<<<<<<<<<<
  2001. * import codecs
  2002. * import unicodedata
  2003. */
  2004. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2005. __Pyx_GOTREF(__pyx_t_5);
  2006. __Pyx_Raise(__pyx_t_5, 0, 0, 0);
  2007. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2008. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2009. }
  2010. /* "lib/Naked/toolshed/c/file.pyx":53
  2011. * if not file_exists(self.filepath):
  2012. * raise IOError("The file specified for the text append does not exist (Naked.toolshed.file.py:append_utf8).")
  2013. * import codecs # <<<<<<<<<<<<<<
  2014. * import unicodedata
  2015. * norm_text = unicodedata.normalize('NFKD', text) # NKFD normalization of the unicode data before write
  2016. */
  2017. __pyx_t_5 = __Pyx_Import(__pyx_n_s_codecs, 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2018. __Pyx_GOTREF(__pyx_t_5);
  2019. __pyx_v_codecs = __pyx_t_5;
  2020. __pyx_t_5 = 0;
  2021. /* "lib/Naked/toolshed/c/file.pyx":54
  2022. * raise IOError("The file specified for the text append does not exist (Naked.toolshed.file.py:append_utf8).")
  2023. * import codecs
  2024. * import unicodedata # <<<<<<<<<<<<<<
  2025. * norm_text = unicodedata.normalize('NFKD', text) # NKFD normalization of the unicode data before write
  2026. * with codecs.open(self.filepath, mode='a', encoding="utf_8") as appender:
  2027. */
  2028. __pyx_t_5 = __Pyx_Import(__pyx_n_s_unicodedata, 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2029. __Pyx_GOTREF(__pyx_t_5);
  2030. __pyx_v_unicodedata = __pyx_t_5;
  2031. __pyx_t_5 = 0;
  2032. /* "lib/Naked/toolshed/c/file.pyx":55
  2033. * import codecs
  2034. * import unicodedata
  2035. * norm_text = unicodedata.normalize('NFKD', text) # NKFD normalization of the unicode data before write # <<<<<<<<<<<<<<
  2036. * with codecs.open(self.filepath, mode='a', encoding="utf_8") as appender:
  2037. * appender.write(norm_text)
  2038. */
  2039. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_unicodedata, __pyx_n_s_normalize); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2040. __Pyx_GOTREF(__pyx_t_5);
  2041. __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2042. __Pyx_GOTREF(__pyx_t_4);
  2043. __Pyx_INCREF(__pyx_n_s_NFKD);
  2044. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_NFKD);
  2045. __Pyx_GIVEREF(__pyx_n_s_NFKD);
  2046. __Pyx_INCREF(__pyx_v_text);
  2047. PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_text);
  2048. __Pyx_GIVEREF(__pyx_v_text);
  2049. __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2050. __Pyx_GOTREF(__pyx_t_8);
  2051. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2052. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2053. __pyx_v_norm_text = __pyx_t_8;
  2054. __pyx_t_8 = 0;
  2055. /* "lib/Naked/toolshed/c/file.pyx":56
  2056. * import unicodedata
  2057. * norm_text = unicodedata.normalize('NFKD', text) # NKFD normalization of the unicode data before write
  2058. * with codecs.open(self.filepath, mode='a', encoding="utf_8") as appender: # <<<<<<<<<<<<<<
  2059. * appender.write(norm_text)
  2060. * except Exception as e:
  2061. */
  2062. /*with:*/ {
  2063. __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_codecs, __pyx_n_s_open); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2064. __Pyx_GOTREF(__pyx_t_8);
  2065. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2066. __Pyx_GOTREF(__pyx_t_4);
  2067. __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2068. __Pyx_GOTREF(__pyx_t_5);
  2069. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
  2070. __Pyx_GIVEREF(__pyx_t_4);
  2071. __pyx_t_4 = 0;
  2072. __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2073. __Pyx_GOTREF(__pyx_t_4);
  2074. if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_mode, __pyx_n_s_a) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2075. if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_encoding, __pyx_n_s_utf_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2076. __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2077. __Pyx_GOTREF(__pyx_t_9);
  2078. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2079. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2080. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2081. __pyx_t_10 = __Pyx_PyObject_LookupSpecial(__pyx_t_9, __pyx_n_s_exit); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2082. __Pyx_GOTREF(__pyx_t_10);
  2083. __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_9, __pyx_n_s_enter); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
  2084. __Pyx_GOTREF(__pyx_t_4);
  2085. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
  2086. __Pyx_GOTREF(__pyx_t_5);
  2087. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2088. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  2089. /*try:*/ {
  2090. {
  2091. __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
  2092. __Pyx_XGOTREF(__pyx_t_11);
  2093. __Pyx_XGOTREF(__pyx_t_12);
  2094. __Pyx_XGOTREF(__pyx_t_13);
  2095. /*try:*/ {
  2096. __Pyx_INCREF(__pyx_t_5);
  2097. __pyx_v_appender = __pyx_t_5;
  2098. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2099. /* "lib/Naked/toolshed/c/file.pyx":57
  2100. * norm_text = unicodedata.normalize('NFKD', text) # NKFD normalization of the unicode data before write
  2101. * with codecs.open(self.filepath, mode='a', encoding="utf_8") as appender:
  2102. * appender.write(norm_text) # <<<<<<<<<<<<<<
  2103. * except Exception as e:
  2104. * if DEBUG_FLAG:
  2105. */
  2106. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_appender, __pyx_n_s_write); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  2107. __Pyx_GOTREF(__pyx_t_5);
  2108. __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  2109. __Pyx_GOTREF(__pyx_t_9);
  2110. __Pyx_INCREF(__pyx_v_norm_text);
  2111. PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_norm_text);
  2112. __Pyx_GIVEREF(__pyx_v_norm_text);
  2113. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  2114. __Pyx_GOTREF(__pyx_t_4);
  2115. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2116. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  2117. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2118. }
  2119. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  2120. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  2121. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  2122. goto __pyx_L25_try_end;
  2123. __pyx_L18_error:;
  2124. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  2125. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2126. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  2127. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  2128. /* "lib/Naked/toolshed/c/file.pyx":56
  2129. * import unicodedata
  2130. * norm_text = unicodedata.normalize('NFKD', text) # NKFD normalization of the unicode data before write
  2131. * with codecs.open(self.filepath, mode='a', encoding="utf_8") as appender: # <<<<<<<<<<<<<<
  2132. * appender.write(norm_text)
  2133. * except Exception as e:
  2134. */
  2135. /*except:*/ {
  2136. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.append_utf8", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2137. if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_9, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  2138. __Pyx_GOTREF(__pyx_t_4);
  2139. __Pyx_GOTREF(__pyx_t_9);
  2140. __Pyx_GOTREF(__pyx_t_5);
  2141. __pyx_t_8 = PyTuple_Pack(3, __pyx_t_4, __pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  2142. __Pyx_GOTREF(__pyx_t_8);
  2143. __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_8, NULL);
  2144. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2145. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2146. if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  2147. __Pyx_GOTREF(__pyx_t_14);
  2148. __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_14);
  2149. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  2150. if (__pyx_t_7 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  2151. __pyx_t_6 = ((!(__pyx_t_7 != 0)) != 0);
  2152. if (__pyx_t_6) {
  2153. __Pyx_GIVEREF(__pyx_t_4);
  2154. __Pyx_GIVEREF(__pyx_t_9);
  2155. __Pyx_XGIVEREF(__pyx_t_5);
  2156. __Pyx_ErrRestore(__pyx_t_4, __pyx_t_9, __pyx_t_5);
  2157. __pyx_t_4 = 0; __pyx_t_9 = 0; __pyx_t_5 = 0;
  2158. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  2159. }
  2160. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2161. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  2162. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2163. goto __pyx_L19_exception_handled;
  2164. }
  2165. __pyx_L20_except_error:;
  2166. __Pyx_XGIVEREF(__pyx_t_11);
  2167. __Pyx_XGIVEREF(__pyx_t_12);
  2168. __Pyx_XGIVEREF(__pyx_t_13);
  2169. __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
  2170. goto __pyx_L3_error;
  2171. __pyx_L19_exception_handled:;
  2172. __Pyx_XGIVEREF(__pyx_t_11);
  2173. __Pyx_XGIVEREF(__pyx_t_12);
  2174. __Pyx_XGIVEREF(__pyx_t_13);
  2175. __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
  2176. __pyx_L25_try_end:;
  2177. }
  2178. }
  2179. /*finally:*/ {
  2180. /*normal exit:*/{
  2181. if (__pyx_t_10) {
  2182. __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_tuple__5, NULL);
  2183. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2184. if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2185. __Pyx_GOTREF(__pyx_t_13);
  2186. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  2187. }
  2188. goto __pyx_L17;
  2189. }
  2190. __pyx_L17:;
  2191. }
  2192. goto __pyx_L30;
  2193. __pyx_L12_error:;
  2194. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2195. goto __pyx_L3_error;
  2196. __pyx_L30:;
  2197. }
  2198. }
  2199. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  2200. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  2201. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  2202. goto __pyx_L10_try_end;
  2203. __pyx_L3_error:;
  2204. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  2205. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  2206. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  2207. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2208. /* "lib/Naked/toolshed/c/file.pyx":58
  2209. * with codecs.open(self.filepath, mode='a', encoding="utf_8") as appender:
  2210. * appender.write(norm_text)
  2211. * except Exception as e: # <<<<<<<<<<<<<<
  2212. * if DEBUG_FLAG:
  2213. * sys.stderr.write("Naked Framework Error: Unable to append text to the file with the append_utf8 method (Naked.toolshed.file.py).")
  2214. */
  2215. __pyx_t_15 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  2216. if (__pyx_t_15) {
  2217. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.append_utf8", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2218. if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_9, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2219. __Pyx_GOTREF(__pyx_t_5);
  2220. __Pyx_GOTREF(__pyx_t_9);
  2221. __Pyx_GOTREF(__pyx_t_4);
  2222. __Pyx_INCREF(__pyx_t_9);
  2223. __pyx_v_e = __pyx_t_9;
  2224. /* "lib/Naked/toolshed/c/file.pyx":59
  2225. * appender.write(norm_text)
  2226. * except Exception as e:
  2227. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  2228. * sys.stderr.write("Naked Framework Error: Unable to append text to the file with the append_utf8 method (Naked.toolshed.file.py).")
  2229. * raise e
  2230. */
  2231. __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2232. __Pyx_GOTREF(__pyx_t_8);
  2233. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2234. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2235. if (__pyx_t_6) {
  2236. /* "lib/Naked/toolshed/c/file.pyx":60
  2237. * except Exception as e:
  2238. * if DEBUG_FLAG:
  2239. * sys.stderr.write("Naked Framework Error: Unable to append text to the file with the append_utf8 method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  2240. * raise e
  2241. *
  2242. */
  2243. __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2244. __Pyx_GOTREF(__pyx_t_8);
  2245. __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_stderr); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2246. __Pyx_GOTREF(__pyx_t_16);
  2247. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2248. __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_write); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2249. __Pyx_GOTREF(__pyx_t_8);
  2250. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  2251. __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2252. __Pyx_GOTREF(__pyx_t_16);
  2253. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2254. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  2255. goto __pyx_L33;
  2256. }
  2257. __pyx_L33:;
  2258. /* "lib/Naked/toolshed/c/file.pyx":61
  2259. * if DEBUG_FLAG:
  2260. * sys.stderr.write("Naked Framework Error: Unable to append text to the file with the append_utf8 method (Naked.toolshed.file.py).")
  2261. * raise e # <<<<<<<<<<<<<<
  2262. *
  2263. * #------------------------------------------------------------------------------
  2264. */
  2265. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  2266. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2267. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2268. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  2269. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2270. goto __pyx_L4_exception_handled;
  2271. }
  2272. goto __pyx_L5_except_error;
  2273. __pyx_L5_except_error:;
  2274. __Pyx_XGIVEREF(__pyx_t_1);
  2275. __Pyx_XGIVEREF(__pyx_t_2);
  2276. __Pyx_XGIVEREF(__pyx_t_3);
  2277. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  2278. goto __pyx_L1_error;
  2279. __pyx_L4_exception_handled:;
  2280. __Pyx_XGIVEREF(__pyx_t_1);
  2281. __Pyx_XGIVEREF(__pyx_t_2);
  2282. __Pyx_XGIVEREF(__pyx_t_3);
  2283. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  2284. __pyx_L10_try_end:;
  2285. }
  2286. /* "lib/Naked/toolshed/c/file.pyx":48
  2287. * # Tests: test_IO.py :: test_file_utf8_readwrite_append
  2288. * #------------------------------------------------------------------------------
  2289. * def append_utf8(self, text): # <<<<<<<<<<<<<<
  2290. * try:
  2291. * from Naked.toolshed.system import file_exists
  2292. */
  2293. /* function exit code */
  2294. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  2295. goto __pyx_L0;
  2296. __pyx_L1_error:;
  2297. __Pyx_XDECREF(__pyx_t_4);
  2298. __Pyx_XDECREF(__pyx_t_5);
  2299. __Pyx_XDECREF(__pyx_t_8);
  2300. __Pyx_XDECREF(__pyx_t_9);
  2301. __Pyx_XDECREF(__pyx_t_16);
  2302. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.append_utf8", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2303. __pyx_r = NULL;
  2304. __pyx_L0:;
  2305. __Pyx_XDECREF(__pyx_v_file_exists);
  2306. __Pyx_XDECREF(__pyx_v_codecs);
  2307. __Pyx_XDECREF(__pyx_v_unicodedata);
  2308. __Pyx_XDECREF(__pyx_v_norm_text);
  2309. __Pyx_XDECREF(__pyx_v_appender);
  2310. __Pyx_XDECREF(__pyx_v_e);
  2311. __Pyx_XGIVEREF(__pyx_r);
  2312. __Pyx_RefNannyFinishContext();
  2313. return __pyx_r;
  2314. }
  2315. /* "lib/Naked/toolshed/c/file.pyx":71
  2316. * # test_file_gzip_utf8_readwrite_explicit_decode
  2317. * #------------------------------------------------------------------------------
  2318. * def gzip(self, text, compression_level=6): # <<<<<<<<<<<<<<
  2319. * try:
  2320. * import gzip
  2321. */
  2322. /* Python wrapper */
  2323. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_7gzip(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  2324. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_7gzip = {__Pyx_NAMESTR("gzip"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_7gzip, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  2325. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_7gzip(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  2326. PyObject *__pyx_v_self = 0;
  2327. PyObject *__pyx_v_text = 0;
  2328. PyObject *__pyx_v_compression_level = 0;
  2329. int __pyx_lineno = 0;
  2330. const char *__pyx_filename = NULL;
  2331. int __pyx_clineno = 0;
  2332. PyObject *__pyx_r = 0;
  2333. __Pyx_RefNannyDeclarations
  2334. __Pyx_RefNannySetupContext("gzip (wrapper)", 0);
  2335. {
  2336. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_text,&__pyx_n_s_compression_level,0};
  2337. PyObject* values[3] = {0,0,0};
  2338. values[2] = ((PyObject *)((PyObject *)__pyx_int_6));
  2339. if (unlikely(__pyx_kwds)) {
  2340. Py_ssize_t kw_args;
  2341. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  2342. switch (pos_args) {
  2343. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  2344. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2345. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2346. case 0: break;
  2347. default: goto __pyx_L5_argtuple_error;
  2348. }
  2349. kw_args = PyDict_Size(__pyx_kwds);
  2350. switch (pos_args) {
  2351. case 0:
  2352. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
  2353. else goto __pyx_L5_argtuple_error;
  2354. case 1:
  2355. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_text)) != 0)) kw_args--;
  2356. else {
  2357. __Pyx_RaiseArgtupleInvalid("gzip", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2358. }
  2359. case 2:
  2360. if (kw_args > 0) {
  2361. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compression_level);
  2362. if (value) { values[2] = value; kw_args--; }
  2363. }
  2364. }
  2365. if (unlikely(kw_args > 0)) {
  2366. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "gzip") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2367. }
  2368. } else {
  2369. switch (PyTuple_GET_SIZE(__pyx_args)) {
  2370. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  2371. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2372. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2373. break;
  2374. default: goto __pyx_L5_argtuple_error;
  2375. }
  2376. }
  2377. __pyx_v_self = values[0];
  2378. __pyx_v_text = values[1];
  2379. __pyx_v_compression_level = values[2];
  2380. }
  2381. goto __pyx_L4_argument_unpacking_done;
  2382. __pyx_L5_argtuple_error:;
  2383. __Pyx_RaiseArgtupleInvalid("gzip", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2384. __pyx_L3_error:;
  2385. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.gzip", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2386. __Pyx_RefNannyFinishContext();
  2387. return NULL;
  2388. __pyx_L4_argument_unpacking_done:;
  2389. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_6gzip(__pyx_self, __pyx_v_self, __pyx_v_text, __pyx_v_compression_level);
  2390. /* function exit code */
  2391. __Pyx_RefNannyFinishContext();
  2392. return __pyx_r;
  2393. }
  2394. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_6gzip(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_text, PyObject *__pyx_v_compression_level) {
  2395. PyObject *__pyx_v_gzip = NULL;
  2396. PyObject *__pyx_v_gzip_writer = NULL;
  2397. CYTHON_UNUSED PyObject *__pyx_v_ue = NULL;
  2398. PyObject *__pyx_v_unicodedata = NULL;
  2399. PyObject *__pyx_v_norm_text = NULL;
  2400. PyObject *__pyx_v_codecs = NULL;
  2401. PyObject *__pyx_v_binary_data = NULL;
  2402. PyObject *__pyx_v_e = NULL;
  2403. PyObject *__pyx_r = NULL;
  2404. __Pyx_RefNannyDeclarations
  2405. PyObject *__pyx_t_1 = NULL;
  2406. PyObject *__pyx_t_2 = NULL;
  2407. PyObject *__pyx_t_3 = NULL;
  2408. PyObject *__pyx_t_4 = NULL;
  2409. PyObject *__pyx_t_5 = NULL;
  2410. int __pyx_t_6;
  2411. int __pyx_t_7;
  2412. PyObject *__pyx_t_8 = NULL;
  2413. PyObject *__pyx_t_9 = NULL;
  2414. PyObject *__pyx_t_10 = NULL;
  2415. PyObject *__pyx_t_11 = NULL;
  2416. PyObject *__pyx_t_12 = NULL;
  2417. PyObject *__pyx_t_13 = NULL;
  2418. PyObject *__pyx_t_14 = NULL;
  2419. int __pyx_t_15;
  2420. PyObject *__pyx_t_16 = NULL;
  2421. PyObject *__pyx_t_17 = NULL;
  2422. PyObject *__pyx_t_18 = NULL;
  2423. int __pyx_lineno = 0;
  2424. const char *__pyx_filename = NULL;
  2425. int __pyx_clineno = 0;
  2426. __Pyx_RefNannySetupContext("gzip", 0);
  2427. /* "lib/Naked/toolshed/c/file.pyx":72
  2428. * #------------------------------------------------------------------------------
  2429. * def gzip(self, text, compression_level=6):
  2430. * try: # <<<<<<<<<<<<<<
  2431. * import gzip
  2432. * if not self.filepath.endswith(".gz"):
  2433. */
  2434. {
  2435. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  2436. __Pyx_XGOTREF(__pyx_t_1);
  2437. __Pyx_XGOTREF(__pyx_t_2);
  2438. __Pyx_XGOTREF(__pyx_t_3);
  2439. /*try:*/ {
  2440. /* "lib/Naked/toolshed/c/file.pyx":73
  2441. * def gzip(self, text, compression_level=6):
  2442. * try:
  2443. * import gzip # <<<<<<<<<<<<<<
  2444. * if not self.filepath.endswith(".gz"):
  2445. * self.filepath = self.filepath + ".gz"
  2446. */
  2447. __pyx_t_4 = __Pyx_Import(__pyx_n_s_gzip, 0, -1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2448. __Pyx_GOTREF(__pyx_t_4);
  2449. __pyx_v_gzip = __pyx_t_4;
  2450. __pyx_t_4 = 0;
  2451. /* "lib/Naked/toolshed/c/file.pyx":74
  2452. * try:
  2453. * import gzip
  2454. * if not self.filepath.endswith(".gz"): # <<<<<<<<<<<<<<
  2455. * self.filepath = self.filepath + ".gz"
  2456. * with gzip.open(self.filepath, 'wb', compresslevel=compression_level) as gzip_writer:
  2457. */
  2458. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2459. __Pyx_GOTREF(__pyx_t_4);
  2460. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_endswith); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2461. __Pyx_GOTREF(__pyx_t_5);
  2462. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2463. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2464. __Pyx_GOTREF(__pyx_t_4);
  2465. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2466. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2467. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2468. __pyx_t_7 = ((!__pyx_t_6) != 0);
  2469. if (__pyx_t_7) {
  2470. /* "lib/Naked/toolshed/c/file.pyx":75
  2471. * import gzip
  2472. * if not self.filepath.endswith(".gz"):
  2473. * self.filepath = self.filepath + ".gz" # <<<<<<<<<<<<<<
  2474. * with gzip.open(self.filepath, 'wb', compresslevel=compression_level) as gzip_writer:
  2475. * gzip_writer.write(text)
  2476. */
  2477. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2478. __Pyx_GOTREF(__pyx_t_4);
  2479. __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_kp_s_gz); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2480. __Pyx_GOTREF(__pyx_t_5);
  2481. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2482. if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_filepath, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2483. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2484. goto __pyx_L11;
  2485. }
  2486. __pyx_L11:;
  2487. /* "lib/Naked/toolshed/c/file.pyx":76
  2488. * if not self.filepath.endswith(".gz"):
  2489. * self.filepath = self.filepath + ".gz"
  2490. * with gzip.open(self.filepath, 'wb', compresslevel=compression_level) as gzip_writer: # <<<<<<<<<<<<<<
  2491. * gzip_writer.write(text)
  2492. * except UnicodeEncodeError as ue:
  2493. */
  2494. /*with:*/ {
  2495. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_gzip, __pyx_n_s_open); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2496. __Pyx_GOTREF(__pyx_t_5);
  2497. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2498. __Pyx_GOTREF(__pyx_t_4);
  2499. __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2500. __Pyx_GOTREF(__pyx_t_8);
  2501. PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4);
  2502. __Pyx_GIVEREF(__pyx_t_4);
  2503. __Pyx_INCREF(__pyx_n_s_wb);
  2504. PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_n_s_wb);
  2505. __Pyx_GIVEREF(__pyx_n_s_wb);
  2506. __pyx_t_4 = 0;
  2507. __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2508. __Pyx_GOTREF(__pyx_t_4);
  2509. if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_compresslevel, __pyx_v_compression_level) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2510. __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, __pyx_t_4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2511. __Pyx_GOTREF(__pyx_t_9);
  2512. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2513. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2514. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2515. __pyx_t_10 = __Pyx_PyObject_LookupSpecial(__pyx_t_9, __pyx_n_s_exit); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2516. __Pyx_GOTREF(__pyx_t_10);
  2517. __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_9, __pyx_n_s_enter); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
  2518. __Pyx_GOTREF(__pyx_t_4);
  2519. __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
  2520. __Pyx_GOTREF(__pyx_t_8);
  2521. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2522. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  2523. /*try:*/ {
  2524. {
  2525. __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
  2526. __Pyx_XGOTREF(__pyx_t_11);
  2527. __Pyx_XGOTREF(__pyx_t_12);
  2528. __Pyx_XGOTREF(__pyx_t_13);
  2529. /*try:*/ {
  2530. __Pyx_INCREF(__pyx_t_8);
  2531. __pyx_v_gzip_writer = __pyx_t_8;
  2532. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2533. /* "lib/Naked/toolshed/c/file.pyx":77
  2534. * self.filepath = self.filepath + ".gz"
  2535. * with gzip.open(self.filepath, 'wb', compresslevel=compression_level) as gzip_writer:
  2536. * gzip_writer.write(text) # <<<<<<<<<<<<<<
  2537. * except UnicodeEncodeError as ue:
  2538. * import unicodedata
  2539. */
  2540. __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_gzip_writer, __pyx_n_s_write); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  2541. __Pyx_GOTREF(__pyx_t_8);
  2542. __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  2543. __Pyx_GOTREF(__pyx_t_9);
  2544. __Pyx_INCREF(__pyx_v_text);
  2545. PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_text);
  2546. __Pyx_GIVEREF(__pyx_v_text);
  2547. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  2548. __Pyx_GOTREF(__pyx_t_4);
  2549. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2550. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  2551. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2552. }
  2553. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  2554. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  2555. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  2556. goto __pyx_L25_try_end;
  2557. __pyx_L18_error:;
  2558. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2559. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  2560. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  2561. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  2562. /* "lib/Naked/toolshed/c/file.pyx":76
  2563. * if not self.filepath.endswith(".gz"):
  2564. * self.filepath = self.filepath + ".gz"
  2565. * with gzip.open(self.filepath, 'wb', compresslevel=compression_level) as gzip_writer: # <<<<<<<<<<<<<<
  2566. * gzip_writer.write(text)
  2567. * except UnicodeEncodeError as ue:
  2568. */
  2569. /*except:*/ {
  2570. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.gzip", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2571. if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_9, &__pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  2572. __Pyx_GOTREF(__pyx_t_4);
  2573. __Pyx_GOTREF(__pyx_t_9);
  2574. __Pyx_GOTREF(__pyx_t_8);
  2575. __pyx_t_5 = PyTuple_Pack(3, __pyx_t_4, __pyx_t_9, __pyx_t_8); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  2576. __Pyx_GOTREF(__pyx_t_5);
  2577. __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_5, NULL);
  2578. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2579. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2580. if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  2581. __Pyx_GOTREF(__pyx_t_14);
  2582. __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_14);
  2583. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  2584. if (__pyx_t_7 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  2585. __pyx_t_6 = ((!(__pyx_t_7 != 0)) != 0);
  2586. if (__pyx_t_6) {
  2587. __Pyx_GIVEREF(__pyx_t_4);
  2588. __Pyx_GIVEREF(__pyx_t_9);
  2589. __Pyx_XGIVEREF(__pyx_t_8);
  2590. __Pyx_ErrRestore(__pyx_t_4, __pyx_t_9, __pyx_t_8);
  2591. __pyx_t_4 = 0; __pyx_t_9 = 0; __pyx_t_8 = 0;
  2592. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  2593. }
  2594. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2595. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  2596. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2597. goto __pyx_L19_exception_handled;
  2598. }
  2599. __pyx_L20_except_error:;
  2600. __Pyx_XGIVEREF(__pyx_t_11);
  2601. __Pyx_XGIVEREF(__pyx_t_12);
  2602. __Pyx_XGIVEREF(__pyx_t_13);
  2603. __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
  2604. goto __pyx_L3_error;
  2605. __pyx_L19_exception_handled:;
  2606. __Pyx_XGIVEREF(__pyx_t_11);
  2607. __Pyx_XGIVEREF(__pyx_t_12);
  2608. __Pyx_XGIVEREF(__pyx_t_13);
  2609. __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
  2610. __pyx_L25_try_end:;
  2611. }
  2612. }
  2613. /*finally:*/ {
  2614. /*normal exit:*/{
  2615. if (__pyx_t_10) {
  2616. __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_tuple__8, NULL);
  2617. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2618. if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2619. __Pyx_GOTREF(__pyx_t_13);
  2620. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  2621. }
  2622. goto __pyx_L17;
  2623. }
  2624. __pyx_L17:;
  2625. }
  2626. goto __pyx_L30;
  2627. __pyx_L12_error:;
  2628. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2629. goto __pyx_L3_error;
  2630. __pyx_L30:;
  2631. }
  2632. }
  2633. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  2634. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  2635. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  2636. goto __pyx_L10_try_end;
  2637. __pyx_L3_error:;
  2638. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2639. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  2640. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  2641. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  2642. /* "lib/Naked/toolshed/c/file.pyx":78
  2643. * with gzip.open(self.filepath, 'wb', compresslevel=compression_level) as gzip_writer:
  2644. * gzip_writer.write(text)
  2645. * except UnicodeEncodeError as ue: # <<<<<<<<<<<<<<
  2646. * import unicodedata
  2647. * norm_text = unicodedata.normalize('NFKD', text) # NKFD normalization of the unicode data before write
  2648. */
  2649. __pyx_t_15 = PyErr_ExceptionMatches(__pyx_builtin_UnicodeEncodeError);
  2650. if (__pyx_t_15) {
  2651. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.gzip", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2652. if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2653. __Pyx_GOTREF(__pyx_t_8);
  2654. __Pyx_GOTREF(__pyx_t_9);
  2655. __Pyx_GOTREF(__pyx_t_4);
  2656. __Pyx_INCREF(__pyx_t_9);
  2657. __pyx_v_ue = __pyx_t_9;
  2658. /* "lib/Naked/toolshed/c/file.pyx":79
  2659. * gzip_writer.write(text)
  2660. * except UnicodeEncodeError as ue:
  2661. * import unicodedata # <<<<<<<<<<<<<<
  2662. * norm_text = unicodedata.normalize('NFKD', text) # NKFD normalization of the unicode data before write
  2663. * import codecs
  2664. */
  2665. __pyx_t_5 = __Pyx_Import(__pyx_n_s_unicodedata, 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2666. __Pyx_GOTREF(__pyx_t_5);
  2667. __pyx_v_unicodedata = __pyx_t_5;
  2668. __pyx_t_5 = 0;
  2669. /* "lib/Naked/toolshed/c/file.pyx":80
  2670. * except UnicodeEncodeError as ue:
  2671. * import unicodedata
  2672. * norm_text = unicodedata.normalize('NFKD', text) # NKFD normalization of the unicode data before write # <<<<<<<<<<<<<<
  2673. * import codecs
  2674. * binary_data = codecs.encode(norm_text, "utf_8")
  2675. */
  2676. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_unicodedata, __pyx_n_s_normalize); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2677. __Pyx_GOTREF(__pyx_t_5);
  2678. __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2679. __Pyx_GOTREF(__pyx_t_16);
  2680. __Pyx_INCREF(__pyx_n_s_NFKD);
  2681. PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_n_s_NFKD);
  2682. __Pyx_GIVEREF(__pyx_n_s_NFKD);
  2683. __Pyx_INCREF(__pyx_v_text);
  2684. PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_v_text);
  2685. __Pyx_GIVEREF(__pyx_v_text);
  2686. __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_16, NULL); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2687. __Pyx_GOTREF(__pyx_t_17);
  2688. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2689. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  2690. __pyx_v_norm_text = __pyx_t_17;
  2691. __pyx_t_17 = 0;
  2692. /* "lib/Naked/toolshed/c/file.pyx":81
  2693. * import unicodedata
  2694. * norm_text = unicodedata.normalize('NFKD', text) # NKFD normalization of the unicode data before write
  2695. * import codecs # <<<<<<<<<<<<<<
  2696. * binary_data = codecs.encode(norm_text, "utf_8")
  2697. * with gzip.open(self.filepath, 'wb', compresslevel=compression_level) as gzip_writer:
  2698. */
  2699. __pyx_t_17 = __Pyx_Import(__pyx_n_s_codecs, 0, -1); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2700. __Pyx_GOTREF(__pyx_t_17);
  2701. __pyx_v_codecs = __pyx_t_17;
  2702. __pyx_t_17 = 0;
  2703. /* "lib/Naked/toolshed/c/file.pyx":82
  2704. * norm_text = unicodedata.normalize('NFKD', text) # NKFD normalization of the unicode data before write
  2705. * import codecs
  2706. * binary_data = codecs.encode(norm_text, "utf_8") # <<<<<<<<<<<<<<
  2707. * with gzip.open(self.filepath, 'wb', compresslevel=compression_level) as gzip_writer:
  2708. * gzip_writer.write(binary_data)
  2709. */
  2710. __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_v_codecs, __pyx_n_s_encode); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2711. __Pyx_GOTREF(__pyx_t_17);
  2712. __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2713. __Pyx_GOTREF(__pyx_t_16);
  2714. __Pyx_INCREF(__pyx_v_norm_text);
  2715. PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_v_norm_text);
  2716. __Pyx_GIVEREF(__pyx_v_norm_text);
  2717. __Pyx_INCREF(__pyx_n_s_utf_8);
  2718. PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_n_s_utf_8);
  2719. __Pyx_GIVEREF(__pyx_n_s_utf_8);
  2720. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_t_16, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2721. __Pyx_GOTREF(__pyx_t_5);
  2722. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  2723. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  2724. __pyx_v_binary_data = __pyx_t_5;
  2725. __pyx_t_5 = 0;
  2726. /* "lib/Naked/toolshed/c/file.pyx":83
  2727. * import codecs
  2728. * binary_data = codecs.encode(norm_text, "utf_8")
  2729. * with gzip.open(self.filepath, 'wb', compresslevel=compression_level) as gzip_writer: # <<<<<<<<<<<<<<
  2730. * gzip_writer.write(binary_data)
  2731. * except Exception as e:
  2732. */
  2733. /*with:*/ {
  2734. if (unlikely(!__pyx_v_gzip)) { __Pyx_RaiseUnboundLocalError("gzip"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;} }
  2735. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_gzip, __pyx_n_s_open); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2736. __Pyx_GOTREF(__pyx_t_5);
  2737. __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2738. __Pyx_GOTREF(__pyx_t_16);
  2739. __pyx_t_17 = PyTuple_New(2); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2740. __Pyx_GOTREF(__pyx_t_17);
  2741. PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_16);
  2742. __Pyx_GIVEREF(__pyx_t_16);
  2743. __Pyx_INCREF(__pyx_n_s_wb);
  2744. PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_n_s_wb);
  2745. __Pyx_GIVEREF(__pyx_n_s_wb);
  2746. __pyx_t_16 = 0;
  2747. __pyx_t_16 = PyDict_New(); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2748. __Pyx_GOTREF(__pyx_t_16);
  2749. if (PyDict_SetItem(__pyx_t_16, __pyx_n_s_compresslevel, __pyx_v_compression_level) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2750. __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_17, __pyx_t_16); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2751. __Pyx_GOTREF(__pyx_t_18);
  2752. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2753. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  2754. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  2755. __pyx_t_10 = __Pyx_PyObject_LookupSpecial(__pyx_t_18, __pyx_n_s_exit); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2756. __Pyx_GOTREF(__pyx_t_10);
  2757. __pyx_t_16 = __Pyx_PyObject_LookupSpecial(__pyx_t_18, __pyx_n_s_enter); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
  2758. __Pyx_GOTREF(__pyx_t_16);
  2759. __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L33_error;}
  2760. __Pyx_GOTREF(__pyx_t_17);
  2761. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  2762. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  2763. /*try:*/ {
  2764. {
  2765. __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
  2766. __Pyx_XGOTREF(__pyx_t_13);
  2767. __Pyx_XGOTREF(__pyx_t_12);
  2768. __Pyx_XGOTREF(__pyx_t_11);
  2769. /*try:*/ {
  2770. __Pyx_INCREF(__pyx_t_17);
  2771. __Pyx_XDECREF_SET(__pyx_v_gzip_writer, __pyx_t_17);
  2772. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  2773. /* "lib/Naked/toolshed/c/file.pyx":84
  2774. * binary_data = codecs.encode(norm_text, "utf_8")
  2775. * with gzip.open(self.filepath, 'wb', compresslevel=compression_level) as gzip_writer:
  2776. * gzip_writer.write(binary_data) # <<<<<<<<<<<<<<
  2777. * except Exception as e:
  2778. * if DEBUG_FLAG:
  2779. */
  2780. __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_v_gzip_writer, __pyx_n_s_write); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
  2781. __Pyx_GOTREF(__pyx_t_17);
  2782. __pyx_t_18 = PyTuple_New(1); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
  2783. __Pyx_GOTREF(__pyx_t_18);
  2784. __Pyx_INCREF(__pyx_v_binary_data);
  2785. PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_v_binary_data);
  2786. __Pyx_GIVEREF(__pyx_v_binary_data);
  2787. __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_t_18, NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L39_error;}
  2788. __Pyx_GOTREF(__pyx_t_16);
  2789. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  2790. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  2791. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  2792. }
  2793. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  2794. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  2795. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  2796. goto __pyx_L46_try_end;
  2797. __pyx_L39_error:;
  2798. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2799. __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
  2800. __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
  2801. __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
  2802. /* "lib/Naked/toolshed/c/file.pyx":83
  2803. * import codecs
  2804. * binary_data = codecs.encode(norm_text, "utf_8")
  2805. * with gzip.open(self.filepath, 'wb', compresslevel=compression_level) as gzip_writer: # <<<<<<<<<<<<<<
  2806. * gzip_writer.write(binary_data)
  2807. * except Exception as e:
  2808. */
  2809. /*except:*/ {
  2810. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.gzip", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2811. if (__Pyx_GetException(&__pyx_t_16, &__pyx_t_18, &__pyx_t_17) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L41_except_error;}
  2812. __Pyx_GOTREF(__pyx_t_16);
  2813. __Pyx_GOTREF(__pyx_t_18);
  2814. __Pyx_GOTREF(__pyx_t_17);
  2815. __pyx_t_5 = PyTuple_Pack(3, __pyx_t_16, __pyx_t_18, __pyx_t_17); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L41_except_error;}
  2816. __Pyx_GOTREF(__pyx_t_5);
  2817. __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_5, NULL);
  2818. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2819. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2820. if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L41_except_error;}
  2821. __Pyx_GOTREF(__pyx_t_14);
  2822. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_14);
  2823. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  2824. if (__pyx_t_6 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L41_except_error;}
  2825. __pyx_t_7 = ((!(__pyx_t_6 != 0)) != 0);
  2826. if (__pyx_t_7) {
  2827. __Pyx_GIVEREF(__pyx_t_16);
  2828. __Pyx_GIVEREF(__pyx_t_18);
  2829. __Pyx_XGIVEREF(__pyx_t_17);
  2830. __Pyx_ErrRestore(__pyx_t_16, __pyx_t_18, __pyx_t_17);
  2831. __pyx_t_16 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0;
  2832. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L41_except_error;}
  2833. }
  2834. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  2835. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  2836. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  2837. goto __pyx_L40_exception_handled;
  2838. }
  2839. __pyx_L41_except_error:;
  2840. __Pyx_XGIVEREF(__pyx_t_13);
  2841. __Pyx_XGIVEREF(__pyx_t_12);
  2842. __Pyx_XGIVEREF(__pyx_t_11);
  2843. __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11);
  2844. goto __pyx_L5_except_error;
  2845. __pyx_L40_exception_handled:;
  2846. __Pyx_XGIVEREF(__pyx_t_13);
  2847. __Pyx_XGIVEREF(__pyx_t_12);
  2848. __Pyx_XGIVEREF(__pyx_t_11);
  2849. __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11);
  2850. __pyx_L46_try_end:;
  2851. }
  2852. }
  2853. /*finally:*/ {
  2854. /*normal exit:*/{
  2855. if (__pyx_t_10) {
  2856. __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_tuple__9, NULL);
  2857. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2858. if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2859. __Pyx_GOTREF(__pyx_t_11);
  2860. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  2861. }
  2862. goto __pyx_L38;
  2863. }
  2864. __pyx_L38:;
  2865. }
  2866. goto __pyx_L51;
  2867. __pyx_L33_error:;
  2868. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  2869. goto __pyx_L5_except_error;
  2870. __pyx_L51:;
  2871. }
  2872. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2873. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  2874. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2875. goto __pyx_L4_exception_handled;
  2876. }
  2877. /* "lib/Naked/toolshed/c/file.pyx":85
  2878. * with gzip.open(self.filepath, 'wb', compresslevel=compression_level) as gzip_writer:
  2879. * gzip_writer.write(binary_data)
  2880. * except Exception as e: # <<<<<<<<<<<<<<
  2881. * if DEBUG_FLAG:
  2882. * sys.stderr.write("Naked Framework Error: unable to gzip compress the file with the gzip method (Naked.toolshed.file.py).")
  2883. */
  2884. __pyx_t_15 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  2885. if (__pyx_t_15) {
  2886. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.gzip", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2887. if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_9, &__pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2888. __Pyx_GOTREF(__pyx_t_4);
  2889. __Pyx_GOTREF(__pyx_t_9);
  2890. __Pyx_GOTREF(__pyx_t_8);
  2891. __Pyx_INCREF(__pyx_t_9);
  2892. __pyx_v_e = __pyx_t_9;
  2893. /* "lib/Naked/toolshed/c/file.pyx":86
  2894. * gzip_writer.write(binary_data)
  2895. * except Exception as e:
  2896. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  2897. * sys.stderr.write("Naked Framework Error: unable to gzip compress the file with the gzip method (Naked.toolshed.file.py).")
  2898. * raise e
  2899. */
  2900. __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2901. __Pyx_GOTREF(__pyx_t_17);
  2902. __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_17); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2903. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  2904. if (__pyx_t_7) {
  2905. /* "lib/Naked/toolshed/c/file.pyx":87
  2906. * except Exception as e:
  2907. * if DEBUG_FLAG:
  2908. * sys.stderr.write("Naked Framework Error: unable to gzip compress the file with the gzip method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  2909. * raise e
  2910. *
  2911. */
  2912. __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2913. __Pyx_GOTREF(__pyx_t_17);
  2914. __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_stderr); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2915. __Pyx_GOTREF(__pyx_t_18);
  2916. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  2917. __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_n_s_write); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2918. __Pyx_GOTREF(__pyx_t_17);
  2919. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  2920. __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2921. __Pyx_GOTREF(__pyx_t_18);
  2922. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  2923. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  2924. goto __pyx_L54;
  2925. }
  2926. __pyx_L54:;
  2927. /* "lib/Naked/toolshed/c/file.pyx":88
  2928. * if DEBUG_FLAG:
  2929. * sys.stderr.write("Naked Framework Error: unable to gzip compress the file with the gzip method (Naked.toolshed.file.py).")
  2930. * raise e # <<<<<<<<<<<<<<
  2931. *
  2932. * #------------------------------------------------------------------------------
  2933. */
  2934. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  2935. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2936. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2937. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  2938. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2939. goto __pyx_L4_exception_handled;
  2940. }
  2941. goto __pyx_L5_except_error;
  2942. __pyx_L5_except_error:;
  2943. __Pyx_XGIVEREF(__pyx_t_1);
  2944. __Pyx_XGIVEREF(__pyx_t_2);
  2945. __Pyx_XGIVEREF(__pyx_t_3);
  2946. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  2947. goto __pyx_L1_error;
  2948. __pyx_L4_exception_handled:;
  2949. __Pyx_XGIVEREF(__pyx_t_1);
  2950. __Pyx_XGIVEREF(__pyx_t_2);
  2951. __Pyx_XGIVEREF(__pyx_t_3);
  2952. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  2953. __pyx_L10_try_end:;
  2954. }
  2955. /* "lib/Naked/toolshed/c/file.pyx":71
  2956. * # test_file_gzip_utf8_readwrite_explicit_decode
  2957. * #------------------------------------------------------------------------------
  2958. * def gzip(self, text, compression_level=6): # <<<<<<<<<<<<<<
  2959. * try:
  2960. * import gzip
  2961. */
  2962. /* function exit code */
  2963. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  2964. goto __pyx_L0;
  2965. __pyx_L1_error:;
  2966. __Pyx_XDECREF(__pyx_t_4);
  2967. __Pyx_XDECREF(__pyx_t_5);
  2968. __Pyx_XDECREF(__pyx_t_8);
  2969. __Pyx_XDECREF(__pyx_t_9);
  2970. __Pyx_XDECREF(__pyx_t_16);
  2971. __Pyx_XDECREF(__pyx_t_17);
  2972. __Pyx_XDECREF(__pyx_t_18);
  2973. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.gzip", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2974. __pyx_r = NULL;
  2975. __pyx_L0:;
  2976. __Pyx_XDECREF(__pyx_v_gzip);
  2977. __Pyx_XDECREF(__pyx_v_gzip_writer);
  2978. __Pyx_XDECREF(__pyx_v_ue);
  2979. __Pyx_XDECREF(__pyx_v_unicodedata);
  2980. __Pyx_XDECREF(__pyx_v_norm_text);
  2981. __Pyx_XDECREF(__pyx_v_codecs);
  2982. __Pyx_XDECREF(__pyx_v_binary_data);
  2983. __Pyx_XDECREF(__pyx_v_e);
  2984. __Pyx_XGIVEREF(__pyx_r);
  2985. __Pyx_RefNannyFinishContext();
  2986. return __pyx_r;
  2987. }
  2988. /* "lib/Naked/toolshed/c/file.pyx":96
  2989. * # test_file_utf8_write_raises_unicodeerror
  2990. * #------------------------------------------------------------------------------
  2991. * def write(self, text): # <<<<<<<<<<<<<<
  2992. * try:
  2993. * with open(self.filepath, 'wt') as writer:
  2994. */
  2995. /* Python wrapper */
  2996. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_9write(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  2997. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_9write = {__Pyx_NAMESTR("write"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_9write, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  2998. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_9write(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  2999. PyObject *__pyx_v_self = 0;
  3000. PyObject *__pyx_v_text = 0;
  3001. int __pyx_lineno = 0;
  3002. const char *__pyx_filename = NULL;
  3003. int __pyx_clineno = 0;
  3004. PyObject *__pyx_r = 0;
  3005. __Pyx_RefNannyDeclarations
  3006. __Pyx_RefNannySetupContext("write (wrapper)", 0);
  3007. {
  3008. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_text,0};
  3009. PyObject* values[2] = {0,0};
  3010. if (unlikely(__pyx_kwds)) {
  3011. Py_ssize_t kw_args;
  3012. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  3013. switch (pos_args) {
  3014. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  3015. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  3016. case 0: break;
  3017. default: goto __pyx_L5_argtuple_error;
  3018. }
  3019. kw_args = PyDict_Size(__pyx_kwds);
  3020. switch (pos_args) {
  3021. case 0:
  3022. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
  3023. else goto __pyx_L5_argtuple_error;
  3024. case 1:
  3025. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_text)) != 0)) kw_args--;
  3026. else {
  3027. __Pyx_RaiseArgtupleInvalid("write", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3028. }
  3029. }
  3030. if (unlikely(kw_args > 0)) {
  3031. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3032. }
  3033. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  3034. goto __pyx_L5_argtuple_error;
  3035. } else {
  3036. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  3037. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  3038. }
  3039. __pyx_v_self = values[0];
  3040. __pyx_v_text = values[1];
  3041. }
  3042. goto __pyx_L4_argument_unpacking_done;
  3043. __pyx_L5_argtuple_error:;
  3044. __Pyx_RaiseArgtupleInvalid("write", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3045. __pyx_L3_error:;
  3046. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.write", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3047. __Pyx_RefNannyFinishContext();
  3048. return NULL;
  3049. __pyx_L4_argument_unpacking_done:;
  3050. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_8write(__pyx_self, __pyx_v_self, __pyx_v_text);
  3051. /* function exit code */
  3052. __Pyx_RefNannyFinishContext();
  3053. return __pyx_r;
  3054. }
  3055. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_8write(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_text) {
  3056. PyObject *__pyx_v_writer = NULL;
  3057. CYTHON_UNUSED PyObject *__pyx_v_ue = NULL;
  3058. PyObject *__pyx_v_e = NULL;
  3059. PyObject *__pyx_r = NULL;
  3060. __Pyx_RefNannyDeclarations
  3061. PyObject *__pyx_t_1 = NULL;
  3062. PyObject *__pyx_t_2 = NULL;
  3063. PyObject *__pyx_t_3 = NULL;
  3064. PyObject *__pyx_t_4 = NULL;
  3065. PyObject *__pyx_t_5 = NULL;
  3066. PyObject *__pyx_t_6 = NULL;
  3067. PyObject *__pyx_t_7 = NULL;
  3068. PyObject *__pyx_t_8 = NULL;
  3069. PyObject *__pyx_t_9 = NULL;
  3070. PyObject *__pyx_t_10 = NULL;
  3071. PyObject *__pyx_t_11 = NULL;
  3072. PyObject *__pyx_t_12 = NULL;
  3073. int __pyx_t_13;
  3074. int __pyx_t_14;
  3075. int __pyx_t_15;
  3076. PyObject *__pyx_t_16 = NULL;
  3077. PyObject *__pyx_t_17 = NULL;
  3078. int __pyx_lineno = 0;
  3079. const char *__pyx_filename = NULL;
  3080. int __pyx_clineno = 0;
  3081. __Pyx_RefNannySetupContext("write", 0);
  3082. /* "lib/Naked/toolshed/c/file.pyx":97
  3083. * #------------------------------------------------------------------------------
  3084. * def write(self, text):
  3085. * try: # <<<<<<<<<<<<<<
  3086. * with open(self.filepath, 'wt') as writer:
  3087. * writer.write(text)
  3088. */
  3089. {
  3090. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  3091. __Pyx_XGOTREF(__pyx_t_1);
  3092. __Pyx_XGOTREF(__pyx_t_2);
  3093. __Pyx_XGOTREF(__pyx_t_3);
  3094. /*try:*/ {
  3095. /* "lib/Naked/toolshed/c/file.pyx":98
  3096. * def write(self, text):
  3097. * try:
  3098. * with open(self.filepath, 'wt') as writer: # <<<<<<<<<<<<<<
  3099. * writer.write(text)
  3100. * except UnicodeEncodeError as ue:
  3101. */
  3102. /*with:*/ {
  3103. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3104. __Pyx_GOTREF(__pyx_t_4);
  3105. __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3106. __Pyx_GOTREF(__pyx_t_5);
  3107. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
  3108. __Pyx_GIVEREF(__pyx_t_4);
  3109. __Pyx_INCREF(__pyx_n_s_wt);
  3110. PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_n_s_wt);
  3111. __Pyx_GIVEREF(__pyx_n_s_wt);
  3112. __pyx_t_4 = 0;
  3113. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3114. __Pyx_GOTREF(__pyx_t_4);
  3115. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3116. __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_n_s_exit); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3117. __Pyx_GOTREF(__pyx_t_6);
  3118. __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_n_s_enter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
  3119. __Pyx_GOTREF(__pyx_t_5);
  3120. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
  3121. __Pyx_GOTREF(__pyx_t_7);
  3122. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3123. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3124. /*try:*/ {
  3125. {
  3126. __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
  3127. __Pyx_XGOTREF(__pyx_t_8);
  3128. __Pyx_XGOTREF(__pyx_t_9);
  3129. __Pyx_XGOTREF(__pyx_t_10);
  3130. /*try:*/ {
  3131. __Pyx_INCREF(__pyx_t_7);
  3132. __pyx_v_writer = __pyx_t_7;
  3133. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3134. /* "lib/Naked/toolshed/c/file.pyx":99
  3135. * try:
  3136. * with open(self.filepath, 'wt') as writer:
  3137. * writer.write(text) # <<<<<<<<<<<<<<
  3138. * except UnicodeEncodeError as ue:
  3139. * self.write_utf8(text) # attempt to write with utf-8 encoding
  3140. */
  3141. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_writer, __pyx_n_s_write); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  3142. __Pyx_GOTREF(__pyx_t_7);
  3143. __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  3144. __Pyx_GOTREF(__pyx_t_4);
  3145. __Pyx_INCREF(__pyx_v_text);
  3146. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_text);
  3147. __Pyx_GIVEREF(__pyx_v_text);
  3148. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  3149. __Pyx_GOTREF(__pyx_t_5);
  3150. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3151. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3152. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3153. }
  3154. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  3155. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  3156. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  3157. goto __pyx_L24_try_end;
  3158. __pyx_L17_error:;
  3159. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3160. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  3161. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3162. /* "lib/Naked/toolshed/c/file.pyx":98
  3163. * def write(self, text):
  3164. * try:
  3165. * with open(self.filepath, 'wt') as writer: # <<<<<<<<<<<<<<
  3166. * writer.write(text)
  3167. * except UnicodeEncodeError as ue:
  3168. */
  3169. /*except:*/ {
  3170. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.write", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3171. if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  3172. __Pyx_GOTREF(__pyx_t_5);
  3173. __Pyx_GOTREF(__pyx_t_4);
  3174. __Pyx_GOTREF(__pyx_t_7);
  3175. __pyx_t_11 = PyTuple_Pack(3, __pyx_t_5, __pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  3176. __Pyx_GOTREF(__pyx_t_11);
  3177. __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, NULL);
  3178. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3179. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  3180. if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  3181. __Pyx_GOTREF(__pyx_t_12);
  3182. __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_12);
  3183. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  3184. if (__pyx_t_13 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  3185. __pyx_t_14 = ((!(__pyx_t_13 != 0)) != 0);
  3186. if (__pyx_t_14) {
  3187. __Pyx_GIVEREF(__pyx_t_5);
  3188. __Pyx_GIVEREF(__pyx_t_4);
  3189. __Pyx_XGIVEREF(__pyx_t_7);
  3190. __Pyx_ErrRestore(__pyx_t_5, __pyx_t_4, __pyx_t_7);
  3191. __pyx_t_5 = 0; __pyx_t_4 = 0; __pyx_t_7 = 0;
  3192. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  3193. }
  3194. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3195. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3196. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3197. goto __pyx_L18_exception_handled;
  3198. }
  3199. __pyx_L19_except_error:;
  3200. __Pyx_XGIVEREF(__pyx_t_8);
  3201. __Pyx_XGIVEREF(__pyx_t_9);
  3202. __Pyx_XGIVEREF(__pyx_t_10);
  3203. __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
  3204. goto __pyx_L3_error;
  3205. __pyx_L18_exception_handled:;
  3206. __Pyx_XGIVEREF(__pyx_t_8);
  3207. __Pyx_XGIVEREF(__pyx_t_9);
  3208. __Pyx_XGIVEREF(__pyx_t_10);
  3209. __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
  3210. __pyx_L24_try_end:;
  3211. }
  3212. }
  3213. /*finally:*/ {
  3214. /*normal exit:*/{
  3215. if (__pyx_t_6) {
  3216. __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__11, NULL);
  3217. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3218. if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3219. __Pyx_GOTREF(__pyx_t_10);
  3220. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3221. }
  3222. goto __pyx_L16;
  3223. }
  3224. __pyx_L16:;
  3225. }
  3226. goto __pyx_L29;
  3227. __pyx_L11_error:;
  3228. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3229. goto __pyx_L3_error;
  3230. __pyx_L29:;
  3231. }
  3232. }
  3233. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3234. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  3235. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3236. goto __pyx_L10_try_end;
  3237. __pyx_L3_error:;
  3238. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  3239. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3240. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  3241. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3242. /* "lib/Naked/toolshed/c/file.pyx":100
  3243. * with open(self.filepath, 'wt') as writer:
  3244. * writer.write(text)
  3245. * except UnicodeEncodeError as ue: # <<<<<<<<<<<<<<
  3246. * self.write_utf8(text) # attempt to write with utf-8 encoding
  3247. * except Exception as e:
  3248. */
  3249. __pyx_t_15 = PyErr_ExceptionMatches(__pyx_builtin_UnicodeEncodeError);
  3250. if (__pyx_t_15) {
  3251. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.write", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3252. if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_4, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3253. __Pyx_GOTREF(__pyx_t_7);
  3254. __Pyx_GOTREF(__pyx_t_4);
  3255. __Pyx_GOTREF(__pyx_t_5);
  3256. __Pyx_INCREF(__pyx_t_4);
  3257. __pyx_v_ue = __pyx_t_4;
  3258. /* "lib/Naked/toolshed/c/file.pyx":101
  3259. * writer.write(text)
  3260. * except UnicodeEncodeError as ue:
  3261. * self.write_utf8(text) # attempt to write with utf-8 encoding # <<<<<<<<<<<<<<
  3262. * except Exception as e:
  3263. * if DEBUG_FLAG:
  3264. */
  3265. __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_write_utf8); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3266. __Pyx_GOTREF(__pyx_t_11);
  3267. __pyx_t_16 = PyTuple_New(1); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3268. __Pyx_GOTREF(__pyx_t_16);
  3269. __Pyx_INCREF(__pyx_v_text);
  3270. PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_v_text);
  3271. __Pyx_GIVEREF(__pyx_v_text);
  3272. __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_16, NULL); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3273. __Pyx_GOTREF(__pyx_t_17);
  3274. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  3275. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  3276. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  3277. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3278. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3279. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3280. goto __pyx_L4_exception_handled;
  3281. }
  3282. /* "lib/Naked/toolshed/c/file.pyx":102
  3283. * except UnicodeEncodeError as ue:
  3284. * self.write_utf8(text) # attempt to write with utf-8 encoding
  3285. * except Exception as e: # <<<<<<<<<<<<<<
  3286. * if DEBUG_FLAG:
  3287. * sys.stderr.write("Naked Framework Error: Unable to write to requested file with the write() method (Naked.toolshed.file.py).")
  3288. */
  3289. __pyx_t_15 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  3290. if (__pyx_t_15) {
  3291. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.write", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3292. if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3293. __Pyx_GOTREF(__pyx_t_5);
  3294. __Pyx_GOTREF(__pyx_t_4);
  3295. __Pyx_GOTREF(__pyx_t_7);
  3296. __Pyx_INCREF(__pyx_t_4);
  3297. __pyx_v_e = __pyx_t_4;
  3298. /* "lib/Naked/toolshed/c/file.pyx":103
  3299. * self.write_utf8(text) # attempt to write with utf-8 encoding
  3300. * except Exception as e:
  3301. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  3302. * sys.stderr.write("Naked Framework Error: Unable to write to requested file with the write() method (Naked.toolshed.file.py).")
  3303. * raise e
  3304. */
  3305. __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3306. __Pyx_GOTREF(__pyx_t_17);
  3307. __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_17); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3308. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  3309. if (__pyx_t_14) {
  3310. /* "lib/Naked/toolshed/c/file.pyx":104
  3311. * except Exception as e:
  3312. * if DEBUG_FLAG:
  3313. * sys.stderr.write("Naked Framework Error: Unable to write to requested file with the write() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  3314. * raise e
  3315. *
  3316. */
  3317. __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3318. __Pyx_GOTREF(__pyx_t_17);
  3319. __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_stderr); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3320. __Pyx_GOTREF(__pyx_t_16);
  3321. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  3322. __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_write); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3323. __Pyx_GOTREF(__pyx_t_17);
  3324. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  3325. __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3326. __Pyx_GOTREF(__pyx_t_16);
  3327. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  3328. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  3329. goto __pyx_L34;
  3330. }
  3331. __pyx_L34:;
  3332. /* "lib/Naked/toolshed/c/file.pyx":105
  3333. * if DEBUG_FLAG:
  3334. * sys.stderr.write("Naked Framework Error: Unable to write to requested file with the write() method (Naked.toolshed.file.py).")
  3335. * raise e # <<<<<<<<<<<<<<
  3336. *
  3337. * #------------------------------------------------------------------------------
  3338. */
  3339. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  3340. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3341. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3342. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3343. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3344. goto __pyx_L4_exception_handled;
  3345. }
  3346. goto __pyx_L5_except_error;
  3347. __pyx_L5_except_error:;
  3348. __Pyx_XGIVEREF(__pyx_t_1);
  3349. __Pyx_XGIVEREF(__pyx_t_2);
  3350. __Pyx_XGIVEREF(__pyx_t_3);
  3351. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  3352. goto __pyx_L1_error;
  3353. __pyx_L4_exception_handled:;
  3354. __Pyx_XGIVEREF(__pyx_t_1);
  3355. __Pyx_XGIVEREF(__pyx_t_2);
  3356. __Pyx_XGIVEREF(__pyx_t_3);
  3357. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  3358. __pyx_L10_try_end:;
  3359. }
  3360. /* "lib/Naked/toolshed/c/file.pyx":96
  3361. * # test_file_utf8_write_raises_unicodeerror
  3362. * #------------------------------------------------------------------------------
  3363. * def write(self, text): # <<<<<<<<<<<<<<
  3364. * try:
  3365. * with open(self.filepath, 'wt') as writer:
  3366. */
  3367. /* function exit code */
  3368. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  3369. goto __pyx_L0;
  3370. __pyx_L1_error:;
  3371. __Pyx_XDECREF(__pyx_t_4);
  3372. __Pyx_XDECREF(__pyx_t_5);
  3373. __Pyx_XDECREF(__pyx_t_7);
  3374. __Pyx_XDECREF(__pyx_t_11);
  3375. __Pyx_XDECREF(__pyx_t_16);
  3376. __Pyx_XDECREF(__pyx_t_17);
  3377. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.write", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3378. __pyx_r = NULL;
  3379. __pyx_L0:;
  3380. __Pyx_XDECREF(__pyx_v_writer);
  3381. __Pyx_XDECREF(__pyx_v_ue);
  3382. __Pyx_XDECREF(__pyx_v_e);
  3383. __Pyx_XGIVEREF(__pyx_r);
  3384. __Pyx_RefNannyFinishContext();
  3385. return __pyx_r;
  3386. }
  3387. /* "lib/Naked/toolshed/c/file.pyx":112
  3388. * # Tests: test_IO.py :: test_file_utf8_readas_writeas
  3389. * #------------------------------------------------------------------------------
  3390. * def write_as(self, text, the_encoding=""): # <<<<<<<<<<<<<<
  3391. * try:
  3392. * if the_encoding == "": #if the developer did not include the encoding type, raise an exception
  3393. */
  3394. /* Python wrapper */
  3395. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_11write_as(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  3396. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_11write_as = {__Pyx_NAMESTR("write_as"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_11write_as, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  3397. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_11write_as(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  3398. PyObject *__pyx_v_self = 0;
  3399. PyObject *__pyx_v_text = 0;
  3400. PyObject *__pyx_v_the_encoding = 0;
  3401. int __pyx_lineno = 0;
  3402. const char *__pyx_filename = NULL;
  3403. int __pyx_clineno = 0;
  3404. PyObject *__pyx_r = 0;
  3405. __Pyx_RefNannyDeclarations
  3406. __Pyx_RefNannySetupContext("write_as (wrapper)", 0);
  3407. {
  3408. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_text,&__pyx_n_s_the_encoding,0};
  3409. PyObject* values[3] = {0,0,0};
  3410. values[2] = ((PyObject *)((PyObject*)__pyx_kp_s__13));
  3411. if (unlikely(__pyx_kwds)) {
  3412. Py_ssize_t kw_args;
  3413. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  3414. switch (pos_args) {
  3415. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  3416. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  3417. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  3418. case 0: break;
  3419. default: goto __pyx_L5_argtuple_error;
  3420. }
  3421. kw_args = PyDict_Size(__pyx_kwds);
  3422. switch (pos_args) {
  3423. case 0:
  3424. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
  3425. else goto __pyx_L5_argtuple_error;
  3426. case 1:
  3427. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_text)) != 0)) kw_args--;
  3428. else {
  3429. __Pyx_RaiseArgtupleInvalid("write_as", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3430. }
  3431. case 2:
  3432. if (kw_args > 0) {
  3433. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_the_encoding);
  3434. if (value) { values[2] = value; kw_args--; }
  3435. }
  3436. }
  3437. if (unlikely(kw_args > 0)) {
  3438. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_as") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3439. }
  3440. } else {
  3441. switch (PyTuple_GET_SIZE(__pyx_args)) {
  3442. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  3443. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  3444. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  3445. break;
  3446. default: goto __pyx_L5_argtuple_error;
  3447. }
  3448. }
  3449. __pyx_v_self = values[0];
  3450. __pyx_v_text = values[1];
  3451. __pyx_v_the_encoding = values[2];
  3452. }
  3453. goto __pyx_L4_argument_unpacking_done;
  3454. __pyx_L5_argtuple_error:;
  3455. __Pyx_RaiseArgtupleInvalid("write_as", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3456. __pyx_L3_error:;
  3457. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.write_as", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3458. __Pyx_RefNannyFinishContext();
  3459. return NULL;
  3460. __pyx_L4_argument_unpacking_done:;
  3461. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_10write_as(__pyx_self, __pyx_v_self, __pyx_v_text, __pyx_v_the_encoding);
  3462. /* function exit code */
  3463. __Pyx_RefNannyFinishContext();
  3464. return __pyx_r;
  3465. }
  3466. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_10write_as(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_text, PyObject *__pyx_v_the_encoding) {
  3467. PyObject *__pyx_v_codecs = NULL;
  3468. PyObject *__pyx_v_f = NULL;
  3469. PyObject *__pyx_v_e = NULL;
  3470. PyObject *__pyx_r = NULL;
  3471. __Pyx_RefNannyDeclarations
  3472. PyObject *__pyx_t_1 = NULL;
  3473. PyObject *__pyx_t_2 = NULL;
  3474. PyObject *__pyx_t_3 = NULL;
  3475. int __pyx_t_4;
  3476. PyObject *__pyx_t_5 = NULL;
  3477. PyObject *__pyx_t_6 = NULL;
  3478. PyObject *__pyx_t_7 = NULL;
  3479. PyObject *__pyx_t_8 = NULL;
  3480. PyObject *__pyx_t_9 = NULL;
  3481. PyObject *__pyx_t_10 = NULL;
  3482. PyObject *__pyx_t_11 = NULL;
  3483. PyObject *__pyx_t_12 = NULL;
  3484. PyObject *__pyx_t_13 = NULL;
  3485. int __pyx_t_14;
  3486. int __pyx_t_15;
  3487. PyObject *__pyx_t_16 = NULL;
  3488. int __pyx_lineno = 0;
  3489. const char *__pyx_filename = NULL;
  3490. int __pyx_clineno = 0;
  3491. __Pyx_RefNannySetupContext("write_as", 0);
  3492. /* "lib/Naked/toolshed/c/file.pyx":113
  3493. * #------------------------------------------------------------------------------
  3494. * def write_as(self, text, the_encoding=""):
  3495. * try: # <<<<<<<<<<<<<<
  3496. * if the_encoding == "": #if the developer did not include the encoding type, raise an exception
  3497. * raise RuntimeError("The text encoding was not specified as an argument to the write_as() method (Naked.toolshed.file.py:write_as).")
  3498. */
  3499. {
  3500. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  3501. __Pyx_XGOTREF(__pyx_t_1);
  3502. __Pyx_XGOTREF(__pyx_t_2);
  3503. __Pyx_XGOTREF(__pyx_t_3);
  3504. /*try:*/ {
  3505. /* "lib/Naked/toolshed/c/file.pyx":114
  3506. * def write_as(self, text, the_encoding=""):
  3507. * try:
  3508. * if the_encoding == "": #if the developer did not include the encoding type, raise an exception # <<<<<<<<<<<<<<
  3509. * raise RuntimeError("The text encoding was not specified as an argument to the write_as() method (Naked.toolshed.file.py:write_as).")
  3510. * import codecs
  3511. */
  3512. __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_the_encoding, __pyx_kp_s__13, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3513. if (__pyx_t_4) {
  3514. /* "lib/Naked/toolshed/c/file.pyx":115
  3515. * try:
  3516. * if the_encoding == "": #if the developer did not include the encoding type, raise an exception
  3517. * raise RuntimeError("The text encoding was not specified as an argument to the write_as() method (Naked.toolshed.file.py:write_as).") # <<<<<<<<<<<<<<
  3518. * import codecs
  3519. * with codecs.open(self.filepath, encoding=the_encoding, mode='w') as f:
  3520. */
  3521. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3522. __Pyx_GOTREF(__pyx_t_5);
  3523. __Pyx_Raise(__pyx_t_5, 0, 0, 0);
  3524. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3525. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3526. }
  3527. /* "lib/Naked/toolshed/c/file.pyx":116
  3528. * if the_encoding == "": #if the developer did not include the encoding type, raise an exception
  3529. * raise RuntimeError("The text encoding was not specified as an argument to the write_as() method (Naked.toolshed.file.py:write_as).")
  3530. * import codecs # <<<<<<<<<<<<<<
  3531. * with codecs.open(self.filepath, encoding=the_encoding, mode='w') as f:
  3532. * f.write(text)
  3533. */
  3534. __pyx_t_5 = __Pyx_Import(__pyx_n_s_codecs, 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3535. __Pyx_GOTREF(__pyx_t_5);
  3536. __pyx_v_codecs = __pyx_t_5;
  3537. __pyx_t_5 = 0;
  3538. /* "lib/Naked/toolshed/c/file.pyx":117
  3539. * raise RuntimeError("The text encoding was not specified as an argument to the write_as() method (Naked.toolshed.file.py:write_as).")
  3540. * import codecs
  3541. * with codecs.open(self.filepath, encoding=the_encoding, mode='w') as f: # <<<<<<<<<<<<<<
  3542. * f.write(text)
  3543. * except Exception as e:
  3544. */
  3545. /*with:*/ {
  3546. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_codecs, __pyx_n_s_open); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3547. __Pyx_GOTREF(__pyx_t_5);
  3548. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3549. __Pyx_GOTREF(__pyx_t_6);
  3550. __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3551. __Pyx_GOTREF(__pyx_t_7);
  3552. PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
  3553. __Pyx_GIVEREF(__pyx_t_6);
  3554. __pyx_t_6 = 0;
  3555. __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3556. __Pyx_GOTREF(__pyx_t_6);
  3557. if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_encoding, __pyx_v_the_encoding) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3558. if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_mode, __pyx_n_s_w) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3559. __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3560. __Pyx_GOTREF(__pyx_t_8);
  3561. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3562. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3563. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3564. __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_8, __pyx_n_s_exit); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3565. __Pyx_GOTREF(__pyx_t_9);
  3566. __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_8, __pyx_n_s_enter); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
  3567. __Pyx_GOTREF(__pyx_t_6);
  3568. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
  3569. __Pyx_GOTREF(__pyx_t_7);
  3570. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3571. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3572. /*try:*/ {
  3573. {
  3574. __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
  3575. __Pyx_XGOTREF(__pyx_t_10);
  3576. __Pyx_XGOTREF(__pyx_t_11);
  3577. __Pyx_XGOTREF(__pyx_t_12);
  3578. /*try:*/ {
  3579. __Pyx_INCREF(__pyx_t_7);
  3580. __pyx_v_f = __pyx_t_7;
  3581. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3582. /* "lib/Naked/toolshed/c/file.pyx":118
  3583. * import codecs
  3584. * with codecs.open(self.filepath, encoding=the_encoding, mode='w') as f:
  3585. * f.write(text) # <<<<<<<<<<<<<<
  3586. * except Exception as e:
  3587. * if DEBUG_FLAG:
  3588. */
  3589. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  3590. __Pyx_GOTREF(__pyx_t_7);
  3591. __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  3592. __Pyx_GOTREF(__pyx_t_8);
  3593. __Pyx_INCREF(__pyx_v_text);
  3594. PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_text);
  3595. __Pyx_GIVEREF(__pyx_v_text);
  3596. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  3597. __Pyx_GOTREF(__pyx_t_6);
  3598. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3599. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3600. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3601. }
  3602. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  3603. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  3604. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  3605. goto __pyx_L25_try_end;
  3606. __pyx_L18_error:;
  3607. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3608. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3609. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  3610. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3611. /* "lib/Naked/toolshed/c/file.pyx":117
  3612. * raise RuntimeError("The text encoding was not specified as an argument to the write_as() method (Naked.toolshed.file.py:write_as).")
  3613. * import codecs
  3614. * with codecs.open(self.filepath, encoding=the_encoding, mode='w') as f: # <<<<<<<<<<<<<<
  3615. * f.write(text)
  3616. * except Exception as e:
  3617. */
  3618. /*except:*/ {
  3619. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.write_as", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3620. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_8, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  3621. __Pyx_GOTREF(__pyx_t_6);
  3622. __Pyx_GOTREF(__pyx_t_8);
  3623. __Pyx_GOTREF(__pyx_t_7);
  3624. __pyx_t_5 = PyTuple_Pack(3, __pyx_t_6, __pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  3625. __Pyx_GOTREF(__pyx_t_5);
  3626. __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_5, NULL);
  3627. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  3628. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3629. if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  3630. __Pyx_GOTREF(__pyx_t_13);
  3631. __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_13);
  3632. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  3633. if (__pyx_t_4 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  3634. __pyx_t_14 = ((!(__pyx_t_4 != 0)) != 0);
  3635. if (__pyx_t_14) {
  3636. __Pyx_GIVEREF(__pyx_t_6);
  3637. __Pyx_GIVEREF(__pyx_t_8);
  3638. __Pyx_XGIVEREF(__pyx_t_7);
  3639. __Pyx_ErrRestore(__pyx_t_6, __pyx_t_8, __pyx_t_7);
  3640. __pyx_t_6 = 0; __pyx_t_8 = 0; __pyx_t_7 = 0;
  3641. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  3642. }
  3643. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3644. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3645. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3646. goto __pyx_L19_exception_handled;
  3647. }
  3648. __pyx_L20_except_error:;
  3649. __Pyx_XGIVEREF(__pyx_t_10);
  3650. __Pyx_XGIVEREF(__pyx_t_11);
  3651. __Pyx_XGIVEREF(__pyx_t_12);
  3652. __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
  3653. goto __pyx_L3_error;
  3654. __pyx_L19_exception_handled:;
  3655. __Pyx_XGIVEREF(__pyx_t_10);
  3656. __Pyx_XGIVEREF(__pyx_t_11);
  3657. __Pyx_XGIVEREF(__pyx_t_12);
  3658. __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
  3659. __pyx_L25_try_end:;
  3660. }
  3661. }
  3662. /*finally:*/ {
  3663. /*normal exit:*/{
  3664. if (__pyx_t_9) {
  3665. __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__15, NULL);
  3666. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  3667. if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3668. __Pyx_GOTREF(__pyx_t_12);
  3669. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  3670. }
  3671. goto __pyx_L17;
  3672. }
  3673. __pyx_L17:;
  3674. }
  3675. goto __pyx_L30;
  3676. __pyx_L12_error:;
  3677. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  3678. goto __pyx_L3_error;
  3679. __pyx_L30:;
  3680. }
  3681. }
  3682. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3683. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  3684. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3685. goto __pyx_L10_try_end;
  3686. __pyx_L3_error:;
  3687. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3688. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3689. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  3690. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3691. /* "lib/Naked/toolshed/c/file.pyx":119
  3692. * with codecs.open(self.filepath, encoding=the_encoding, mode='w') as f:
  3693. * f.write(text)
  3694. * except Exception as e: # <<<<<<<<<<<<<<
  3695. * if DEBUG_FLAG:
  3696. * sys.stderr.write("Naked Framework Error: unable to write file with the specified encoding using the write_as() method (Naked.toolshed.file.py).")
  3697. */
  3698. __pyx_t_15 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  3699. if (__pyx_t_15) {
  3700. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.write_as", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3701. if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3702. __Pyx_GOTREF(__pyx_t_7);
  3703. __Pyx_GOTREF(__pyx_t_8);
  3704. __Pyx_GOTREF(__pyx_t_6);
  3705. __Pyx_INCREF(__pyx_t_8);
  3706. __pyx_v_e = __pyx_t_8;
  3707. /* "lib/Naked/toolshed/c/file.pyx":120
  3708. * f.write(text)
  3709. * except Exception as e:
  3710. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  3711. * sys.stderr.write("Naked Framework Error: unable to write file with the specified encoding using the write_as() method (Naked.toolshed.file.py).")
  3712. * raise e
  3713. */
  3714. __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3715. __Pyx_GOTREF(__pyx_t_5);
  3716. __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3717. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3718. if (__pyx_t_14) {
  3719. /* "lib/Naked/toolshed/c/file.pyx":121
  3720. * except Exception as e:
  3721. * if DEBUG_FLAG:
  3722. * sys.stderr.write("Naked Framework Error: unable to write file with the specified encoding using the write_as() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  3723. * raise e
  3724. *
  3725. */
  3726. __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3727. __Pyx_GOTREF(__pyx_t_5);
  3728. __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_stderr); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3729. __Pyx_GOTREF(__pyx_t_16);
  3730. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3731. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_write); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3732. __Pyx_GOTREF(__pyx_t_5);
  3733. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  3734. __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3735. __Pyx_GOTREF(__pyx_t_16);
  3736. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3737. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  3738. goto __pyx_L33;
  3739. }
  3740. __pyx_L33:;
  3741. /* "lib/Naked/toolshed/c/file.pyx":122
  3742. * if DEBUG_FLAG:
  3743. * sys.stderr.write("Naked Framework Error: unable to write file with the specified encoding using the write_as() method (Naked.toolshed.file.py).")
  3744. * raise e # <<<<<<<<<<<<<<
  3745. *
  3746. * #------------------------------------------------------------------------------
  3747. */
  3748. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  3749. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  3750. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3751. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3752. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3753. goto __pyx_L4_exception_handled;
  3754. }
  3755. goto __pyx_L5_except_error;
  3756. __pyx_L5_except_error:;
  3757. __Pyx_XGIVEREF(__pyx_t_1);
  3758. __Pyx_XGIVEREF(__pyx_t_2);
  3759. __Pyx_XGIVEREF(__pyx_t_3);
  3760. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  3761. goto __pyx_L1_error;
  3762. __pyx_L4_exception_handled:;
  3763. __Pyx_XGIVEREF(__pyx_t_1);
  3764. __Pyx_XGIVEREF(__pyx_t_2);
  3765. __Pyx_XGIVEREF(__pyx_t_3);
  3766. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  3767. __pyx_L10_try_end:;
  3768. }
  3769. /* "lib/Naked/toolshed/c/file.pyx":112
  3770. * # Tests: test_IO.py :: test_file_utf8_readas_writeas
  3771. * #------------------------------------------------------------------------------
  3772. * def write_as(self, text, the_encoding=""): # <<<<<<<<<<<<<<
  3773. * try:
  3774. * if the_encoding == "": #if the developer did not include the encoding type, raise an exception
  3775. */
  3776. /* function exit code */
  3777. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  3778. goto __pyx_L0;
  3779. __pyx_L1_error:;
  3780. __Pyx_XDECREF(__pyx_t_5);
  3781. __Pyx_XDECREF(__pyx_t_6);
  3782. __Pyx_XDECREF(__pyx_t_7);
  3783. __Pyx_XDECREF(__pyx_t_8);
  3784. __Pyx_XDECREF(__pyx_t_16);
  3785. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.write_as", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3786. __pyx_r = NULL;
  3787. __pyx_L0:;
  3788. __Pyx_XDECREF(__pyx_v_codecs);
  3789. __Pyx_XDECREF(__pyx_v_f);
  3790. __Pyx_XDECREF(__pyx_v_e);
  3791. __Pyx_XGIVEREF(__pyx_r);
  3792. __Pyx_RefNannyFinishContext();
  3793. return __pyx_r;
  3794. }
  3795. /* "lib/Naked/toolshed/c/file.pyx":129
  3796. * # Tests: test_IO.py :: test_file_bin_readwrite
  3797. * #------------------------------------------------------------------------------
  3798. * def write_bin(self, binary_data): # <<<<<<<<<<<<<<
  3799. * try:
  3800. * with open(self.filepath, 'wb') as bin_writer:
  3801. */
  3802. /* Python wrapper */
  3803. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_13write_bin(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  3804. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_13write_bin = {__Pyx_NAMESTR("write_bin"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_13write_bin, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  3805. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_13write_bin(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  3806. PyObject *__pyx_v_self = 0;
  3807. PyObject *__pyx_v_binary_data = 0;
  3808. int __pyx_lineno = 0;
  3809. const char *__pyx_filename = NULL;
  3810. int __pyx_clineno = 0;
  3811. PyObject *__pyx_r = 0;
  3812. __Pyx_RefNannyDeclarations
  3813. __Pyx_RefNannySetupContext("write_bin (wrapper)", 0);
  3814. {
  3815. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_binary_data,0};
  3816. PyObject* values[2] = {0,0};
  3817. if (unlikely(__pyx_kwds)) {
  3818. Py_ssize_t kw_args;
  3819. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  3820. switch (pos_args) {
  3821. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  3822. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  3823. case 0: break;
  3824. default: goto __pyx_L5_argtuple_error;
  3825. }
  3826. kw_args = PyDict_Size(__pyx_kwds);
  3827. switch (pos_args) {
  3828. case 0:
  3829. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
  3830. else goto __pyx_L5_argtuple_error;
  3831. case 1:
  3832. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_binary_data)) != 0)) kw_args--;
  3833. else {
  3834. __Pyx_RaiseArgtupleInvalid("write_bin", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3835. }
  3836. }
  3837. if (unlikely(kw_args > 0)) {
  3838. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_bin") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3839. }
  3840. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  3841. goto __pyx_L5_argtuple_error;
  3842. } else {
  3843. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  3844. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  3845. }
  3846. __pyx_v_self = values[0];
  3847. __pyx_v_binary_data = values[1];
  3848. }
  3849. goto __pyx_L4_argument_unpacking_done;
  3850. __pyx_L5_argtuple_error:;
  3851. __Pyx_RaiseArgtupleInvalid("write_bin", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3852. __pyx_L3_error:;
  3853. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.write_bin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3854. __Pyx_RefNannyFinishContext();
  3855. return NULL;
  3856. __pyx_L4_argument_unpacking_done:;
  3857. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_12write_bin(__pyx_self, __pyx_v_self, __pyx_v_binary_data);
  3858. /* function exit code */
  3859. __Pyx_RefNannyFinishContext();
  3860. return __pyx_r;
  3861. }
  3862. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_12write_bin(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_binary_data) {
  3863. PyObject *__pyx_v_bin_writer = NULL;
  3864. PyObject *__pyx_v_e = NULL;
  3865. PyObject *__pyx_r = NULL;
  3866. __Pyx_RefNannyDeclarations
  3867. PyObject *__pyx_t_1 = NULL;
  3868. PyObject *__pyx_t_2 = NULL;
  3869. PyObject *__pyx_t_3 = NULL;
  3870. PyObject *__pyx_t_4 = NULL;
  3871. PyObject *__pyx_t_5 = NULL;
  3872. PyObject *__pyx_t_6 = NULL;
  3873. PyObject *__pyx_t_7 = NULL;
  3874. PyObject *__pyx_t_8 = NULL;
  3875. PyObject *__pyx_t_9 = NULL;
  3876. PyObject *__pyx_t_10 = NULL;
  3877. PyObject *__pyx_t_11 = NULL;
  3878. PyObject *__pyx_t_12 = NULL;
  3879. int __pyx_t_13;
  3880. int __pyx_t_14;
  3881. int __pyx_t_15;
  3882. PyObject *__pyx_t_16 = NULL;
  3883. int __pyx_lineno = 0;
  3884. const char *__pyx_filename = NULL;
  3885. int __pyx_clineno = 0;
  3886. __Pyx_RefNannySetupContext("write_bin", 0);
  3887. /* "lib/Naked/toolshed/c/file.pyx":130
  3888. * #------------------------------------------------------------------------------
  3889. * def write_bin(self, binary_data):
  3890. * try: # <<<<<<<<<<<<<<
  3891. * with open(self.filepath, 'wb') as bin_writer:
  3892. * bin_writer.write(binary_data)
  3893. */
  3894. {
  3895. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  3896. __Pyx_XGOTREF(__pyx_t_1);
  3897. __Pyx_XGOTREF(__pyx_t_2);
  3898. __Pyx_XGOTREF(__pyx_t_3);
  3899. /*try:*/ {
  3900. /* "lib/Naked/toolshed/c/file.pyx":131
  3901. * def write_bin(self, binary_data):
  3902. * try:
  3903. * with open(self.filepath, 'wb') as bin_writer: # <<<<<<<<<<<<<<
  3904. * bin_writer.write(binary_data)
  3905. * except Exception as e:
  3906. */
  3907. /*with:*/ {
  3908. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3909. __Pyx_GOTREF(__pyx_t_4);
  3910. __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3911. __Pyx_GOTREF(__pyx_t_5);
  3912. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
  3913. __Pyx_GIVEREF(__pyx_t_4);
  3914. __Pyx_INCREF(__pyx_n_s_wb);
  3915. PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_n_s_wb);
  3916. __Pyx_GIVEREF(__pyx_n_s_wb);
  3917. __pyx_t_4 = 0;
  3918. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3919. __Pyx_GOTREF(__pyx_t_4);
  3920. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3921. __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_n_s_exit); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3922. __Pyx_GOTREF(__pyx_t_6);
  3923. __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_n_s_enter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
  3924. __Pyx_GOTREF(__pyx_t_5);
  3925. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
  3926. __Pyx_GOTREF(__pyx_t_7);
  3927. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3928. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3929. /*try:*/ {
  3930. {
  3931. __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
  3932. __Pyx_XGOTREF(__pyx_t_8);
  3933. __Pyx_XGOTREF(__pyx_t_9);
  3934. __Pyx_XGOTREF(__pyx_t_10);
  3935. /*try:*/ {
  3936. __Pyx_INCREF(__pyx_t_7);
  3937. __pyx_v_bin_writer = __pyx_t_7;
  3938. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3939. /* "lib/Naked/toolshed/c/file.pyx":132
  3940. * try:
  3941. * with open(self.filepath, 'wb') as bin_writer:
  3942. * bin_writer.write(binary_data) # <<<<<<<<<<<<<<
  3943. * except Exception as e:
  3944. * if DEBUG_FLAG:
  3945. */
  3946. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_bin_writer, __pyx_n_s_write); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  3947. __Pyx_GOTREF(__pyx_t_7);
  3948. __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  3949. __Pyx_GOTREF(__pyx_t_4);
  3950. __Pyx_INCREF(__pyx_v_binary_data);
  3951. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_binary_data);
  3952. __Pyx_GIVEREF(__pyx_v_binary_data);
  3953. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  3954. __Pyx_GOTREF(__pyx_t_5);
  3955. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3956. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3957. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3958. }
  3959. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  3960. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  3961. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  3962. goto __pyx_L24_try_end;
  3963. __pyx_L17_error:;
  3964. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  3965. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  3966. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3967. /* "lib/Naked/toolshed/c/file.pyx":131
  3968. * def write_bin(self, binary_data):
  3969. * try:
  3970. * with open(self.filepath, 'wb') as bin_writer: # <<<<<<<<<<<<<<
  3971. * bin_writer.write(binary_data)
  3972. * except Exception as e:
  3973. */
  3974. /*except:*/ {
  3975. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.write_bin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3976. if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  3977. __Pyx_GOTREF(__pyx_t_5);
  3978. __Pyx_GOTREF(__pyx_t_4);
  3979. __Pyx_GOTREF(__pyx_t_7);
  3980. __pyx_t_11 = PyTuple_Pack(3, __pyx_t_5, __pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  3981. __Pyx_GOTREF(__pyx_t_11);
  3982. __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, NULL);
  3983. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  3984. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  3985. if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  3986. __Pyx_GOTREF(__pyx_t_12);
  3987. __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_12);
  3988. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  3989. if (__pyx_t_13 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  3990. __pyx_t_14 = ((!(__pyx_t_13 != 0)) != 0);
  3991. if (__pyx_t_14) {
  3992. __Pyx_GIVEREF(__pyx_t_5);
  3993. __Pyx_GIVEREF(__pyx_t_4);
  3994. __Pyx_XGIVEREF(__pyx_t_7);
  3995. __Pyx_ErrRestore(__pyx_t_5, __pyx_t_4, __pyx_t_7);
  3996. __pyx_t_5 = 0; __pyx_t_4 = 0; __pyx_t_7 = 0;
  3997. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  3998. }
  3999. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4000. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4001. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  4002. goto __pyx_L18_exception_handled;
  4003. }
  4004. __pyx_L19_except_error:;
  4005. __Pyx_XGIVEREF(__pyx_t_8);
  4006. __Pyx_XGIVEREF(__pyx_t_9);
  4007. __Pyx_XGIVEREF(__pyx_t_10);
  4008. __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
  4009. goto __pyx_L3_error;
  4010. __pyx_L18_exception_handled:;
  4011. __Pyx_XGIVEREF(__pyx_t_8);
  4012. __Pyx_XGIVEREF(__pyx_t_9);
  4013. __Pyx_XGIVEREF(__pyx_t_10);
  4014. __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
  4015. __pyx_L24_try_end:;
  4016. }
  4017. }
  4018. /*finally:*/ {
  4019. /*normal exit:*/{
  4020. if (__pyx_t_6) {
  4021. __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__17, NULL);
  4022. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4023. if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4024. __Pyx_GOTREF(__pyx_t_10);
  4025. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  4026. }
  4027. goto __pyx_L16;
  4028. }
  4029. __pyx_L16:;
  4030. }
  4031. goto __pyx_L29;
  4032. __pyx_L11_error:;
  4033. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4034. goto __pyx_L3_error;
  4035. __pyx_L29:;
  4036. }
  4037. }
  4038. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  4039. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  4040. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  4041. goto __pyx_L10_try_end;
  4042. __pyx_L3_error:;
  4043. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  4044. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4045. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  4046. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  4047. /* "lib/Naked/toolshed/c/file.pyx":133
  4048. * with open(self.filepath, 'wb') as bin_writer:
  4049. * bin_writer.write(binary_data)
  4050. * except Exception as e: # <<<<<<<<<<<<<<
  4051. * if DEBUG_FLAG:
  4052. * sys.stderr.write("Naked Framework Error: Unable to write binary data to file with the write_bin method (Naked.toolshed.file.py).")
  4053. */
  4054. __pyx_t_15 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  4055. if (__pyx_t_15) {
  4056. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.write_bin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4057. if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_4, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  4058. __Pyx_GOTREF(__pyx_t_7);
  4059. __Pyx_GOTREF(__pyx_t_4);
  4060. __Pyx_GOTREF(__pyx_t_5);
  4061. __Pyx_INCREF(__pyx_t_4);
  4062. __pyx_v_e = __pyx_t_4;
  4063. /* "lib/Naked/toolshed/c/file.pyx":134
  4064. * bin_writer.write(binary_data)
  4065. * except Exception as e:
  4066. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  4067. * sys.stderr.write("Naked Framework Error: Unable to write binary data to file with the write_bin method (Naked.toolshed.file.py).")
  4068. * raise e
  4069. */
  4070. __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  4071. __Pyx_GOTREF(__pyx_t_11);
  4072. __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  4073. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  4074. if (__pyx_t_14) {
  4075. /* "lib/Naked/toolshed/c/file.pyx":135
  4076. * except Exception as e:
  4077. * if DEBUG_FLAG:
  4078. * sys.stderr.write("Naked Framework Error: Unable to write binary data to file with the write_bin method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  4079. * raise e
  4080. *
  4081. */
  4082. __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  4083. __Pyx_GOTREF(__pyx_t_11);
  4084. __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_stderr); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  4085. __Pyx_GOTREF(__pyx_t_16);
  4086. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  4087. __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_write); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  4088. __Pyx_GOTREF(__pyx_t_11);
  4089. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  4090. __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  4091. __Pyx_GOTREF(__pyx_t_16);
  4092. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  4093. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  4094. goto __pyx_L32;
  4095. }
  4096. __pyx_L32:;
  4097. /* "lib/Naked/toolshed/c/file.pyx":136
  4098. * if DEBUG_FLAG:
  4099. * sys.stderr.write("Naked Framework Error: Unable to write binary data to file with the write_bin method (Naked.toolshed.file.py).")
  4100. * raise e # <<<<<<<<<<<<<<
  4101. *
  4102. * #------------------------------------------------------------------------------
  4103. */
  4104. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  4105. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  4106. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  4107. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4108. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4109. goto __pyx_L4_exception_handled;
  4110. }
  4111. goto __pyx_L5_except_error;
  4112. __pyx_L5_except_error:;
  4113. __Pyx_XGIVEREF(__pyx_t_1);
  4114. __Pyx_XGIVEREF(__pyx_t_2);
  4115. __Pyx_XGIVEREF(__pyx_t_3);
  4116. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  4117. goto __pyx_L1_error;
  4118. __pyx_L4_exception_handled:;
  4119. __Pyx_XGIVEREF(__pyx_t_1);
  4120. __Pyx_XGIVEREF(__pyx_t_2);
  4121. __Pyx_XGIVEREF(__pyx_t_3);
  4122. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  4123. __pyx_L10_try_end:;
  4124. }
  4125. /* "lib/Naked/toolshed/c/file.pyx":129
  4126. * # Tests: test_IO.py :: test_file_bin_readwrite
  4127. * #------------------------------------------------------------------------------
  4128. * def write_bin(self, binary_data): # <<<<<<<<<<<<<<
  4129. * try:
  4130. * with open(self.filepath, 'wb') as bin_writer:
  4131. */
  4132. /* function exit code */
  4133. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4134. goto __pyx_L0;
  4135. __pyx_L1_error:;
  4136. __Pyx_XDECREF(__pyx_t_4);
  4137. __Pyx_XDECREF(__pyx_t_5);
  4138. __Pyx_XDECREF(__pyx_t_7);
  4139. __Pyx_XDECREF(__pyx_t_11);
  4140. __Pyx_XDECREF(__pyx_t_16);
  4141. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.write_bin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4142. __pyx_r = NULL;
  4143. __pyx_L0:;
  4144. __Pyx_XDECREF(__pyx_v_bin_writer);
  4145. __Pyx_XDECREF(__pyx_v_e);
  4146. __Pyx_XGIVEREF(__pyx_r);
  4147. __Pyx_RefNannyFinishContext();
  4148. return __pyx_r;
  4149. }
  4150. /* "lib/Naked/toolshed/c/file.pyx":144
  4151. * # Tests: test_IO.py :: test_file_ascii_safewrite, test_file_utf8_safewrite
  4152. * #------------------------------------------------------------------------------
  4153. * def safe_write(self, text): # <<<<<<<<<<<<<<
  4154. * import os.path
  4155. * if not os.path.exists(self.filepath): # if the file does not exist, then can write
  4156. */
  4157. /* Python wrapper */
  4158. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_15safe_write(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  4159. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_15safe_write = {__Pyx_NAMESTR("safe_write"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_15safe_write, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  4160. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_15safe_write(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  4161. PyObject *__pyx_v_self = 0;
  4162. PyObject *__pyx_v_text = 0;
  4163. int __pyx_lineno = 0;
  4164. const char *__pyx_filename = NULL;
  4165. int __pyx_clineno = 0;
  4166. PyObject *__pyx_r = 0;
  4167. __Pyx_RefNannyDeclarations
  4168. __Pyx_RefNannySetupContext("safe_write (wrapper)", 0);
  4169. {
  4170. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_text,0};
  4171. PyObject* values[2] = {0,0};
  4172. if (unlikely(__pyx_kwds)) {
  4173. Py_ssize_t kw_args;
  4174. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  4175. switch (pos_args) {
  4176. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  4177. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  4178. case 0: break;
  4179. default: goto __pyx_L5_argtuple_error;
  4180. }
  4181. kw_args = PyDict_Size(__pyx_kwds);
  4182. switch (pos_args) {
  4183. case 0:
  4184. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
  4185. else goto __pyx_L5_argtuple_error;
  4186. case 1:
  4187. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_text)) != 0)) kw_args--;
  4188. else {
  4189. __Pyx_RaiseArgtupleInvalid("safe_write", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4190. }
  4191. }
  4192. if (unlikely(kw_args > 0)) {
  4193. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "safe_write") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4194. }
  4195. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  4196. goto __pyx_L5_argtuple_error;
  4197. } else {
  4198. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  4199. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  4200. }
  4201. __pyx_v_self = values[0];
  4202. __pyx_v_text = values[1];
  4203. }
  4204. goto __pyx_L4_argument_unpacking_done;
  4205. __pyx_L5_argtuple_error:;
  4206. __Pyx_RaiseArgtupleInvalid("safe_write", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4207. __pyx_L3_error:;
  4208. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.safe_write", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4209. __Pyx_RefNannyFinishContext();
  4210. return NULL;
  4211. __pyx_L4_argument_unpacking_done:;
  4212. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_14safe_write(__pyx_self, __pyx_v_self, __pyx_v_text);
  4213. /* function exit code */
  4214. __Pyx_RefNannyFinishContext();
  4215. return __pyx_r;
  4216. }
  4217. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_14safe_write(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_text) {
  4218. PyObject *__pyx_v_os = NULL;
  4219. PyObject *__pyx_v_writer = NULL;
  4220. CYTHON_UNUSED PyObject *__pyx_v_ue = NULL;
  4221. PyObject *__pyx_v_e = NULL;
  4222. PyObject *__pyx_r = NULL;
  4223. __Pyx_RefNannyDeclarations
  4224. PyObject *__pyx_t_1 = NULL;
  4225. PyObject *__pyx_t_2 = NULL;
  4226. PyObject *__pyx_t_3 = NULL;
  4227. int __pyx_t_4;
  4228. int __pyx_t_5;
  4229. PyObject *__pyx_t_6 = NULL;
  4230. PyObject *__pyx_t_7 = NULL;
  4231. PyObject *__pyx_t_8 = NULL;
  4232. PyObject *__pyx_t_9 = NULL;
  4233. PyObject *__pyx_t_10 = NULL;
  4234. PyObject *__pyx_t_11 = NULL;
  4235. PyObject *__pyx_t_12 = NULL;
  4236. PyObject *__pyx_t_13 = NULL;
  4237. PyObject *__pyx_t_14 = NULL;
  4238. int __pyx_t_15;
  4239. PyObject *__pyx_t_16 = NULL;
  4240. PyObject *__pyx_t_17 = NULL;
  4241. int __pyx_lineno = 0;
  4242. const char *__pyx_filename = NULL;
  4243. int __pyx_clineno = 0;
  4244. __Pyx_RefNannySetupContext("safe_write", 0);
  4245. /* "lib/Naked/toolshed/c/file.pyx":145
  4246. * #------------------------------------------------------------------------------
  4247. * def safe_write(self, text):
  4248. * import os.path # <<<<<<<<<<<<<<
  4249. * if not os.path.exists(self.filepath): # if the file does not exist, then can write
  4250. * try:
  4251. */
  4252. __pyx_t_1 = __Pyx_Import(__pyx_n_s_os_path, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4253. __Pyx_GOTREF(__pyx_t_1);
  4254. __pyx_v_os = __pyx_t_1;
  4255. __pyx_t_1 = 0;
  4256. /* "lib/Naked/toolshed/c/file.pyx":146
  4257. * def safe_write(self, text):
  4258. * import os.path
  4259. * if not os.path.exists(self.filepath): # if the file does not exist, then can write # <<<<<<<<<<<<<<
  4260. * try:
  4261. * with open(self.filepath, 'wt') as writer:
  4262. */
  4263. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_os, __pyx_n_s_path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4264. __Pyx_GOTREF(__pyx_t_1);
  4265. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_exists); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4266. __Pyx_GOTREF(__pyx_t_2);
  4267. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4268. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4269. __Pyx_GOTREF(__pyx_t_1);
  4270. __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4271. __Pyx_GOTREF(__pyx_t_3);
  4272. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  4273. __Pyx_GIVEREF(__pyx_t_1);
  4274. __pyx_t_1 = 0;
  4275. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4276. __Pyx_GOTREF(__pyx_t_1);
  4277. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4278. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4279. __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4280. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4281. __pyx_t_5 = ((!__pyx_t_4) != 0);
  4282. if (__pyx_t_5) {
  4283. /* "lib/Naked/toolshed/c/file.pyx":147
  4284. * import os.path
  4285. * if not os.path.exists(self.filepath): # if the file does not exist, then can write
  4286. * try: # <<<<<<<<<<<<<<
  4287. * with open(self.filepath, 'wt') as writer:
  4288. * writer.write(text)
  4289. */
  4290. {
  4291. __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
  4292. __Pyx_XGOTREF(__pyx_t_6);
  4293. __Pyx_XGOTREF(__pyx_t_7);
  4294. __Pyx_XGOTREF(__pyx_t_8);
  4295. /*try:*/ {
  4296. /* "lib/Naked/toolshed/c/file.pyx":148
  4297. * if not os.path.exists(self.filepath): # if the file does not exist, then can write
  4298. * try:
  4299. * with open(self.filepath, 'wt') as writer: # <<<<<<<<<<<<<<
  4300. * writer.write(text)
  4301. * return True
  4302. */
  4303. /*with:*/ {
  4304. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
  4305. __Pyx_GOTREF(__pyx_t_1);
  4306. __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
  4307. __Pyx_GOTREF(__pyx_t_3);
  4308. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  4309. __Pyx_GIVEREF(__pyx_t_1);
  4310. __Pyx_INCREF(__pyx_n_s_wt);
  4311. PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_wt);
  4312. __Pyx_GIVEREF(__pyx_n_s_wt);
  4313. __pyx_t_1 = 0;
  4314. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
  4315. __Pyx_GOTREF(__pyx_t_1);
  4316. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4317. __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
  4318. __Pyx_GOTREF(__pyx_t_9);
  4319. __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
  4320. __Pyx_GOTREF(__pyx_t_3);
  4321. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
  4322. __Pyx_GOTREF(__pyx_t_2);
  4323. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4324. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4325. /*try:*/ {
  4326. {
  4327. __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
  4328. __Pyx_XGOTREF(__pyx_t_10);
  4329. __Pyx_XGOTREF(__pyx_t_11);
  4330. __Pyx_XGOTREF(__pyx_t_12);
  4331. /*try:*/ {
  4332. __Pyx_INCREF(__pyx_t_2);
  4333. __pyx_v_writer = __pyx_t_2;
  4334. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4335. /* "lib/Naked/toolshed/c/file.pyx":149
  4336. * try:
  4337. * with open(self.filepath, 'wt') as writer:
  4338. * writer.write(text) # <<<<<<<<<<<<<<
  4339. * return True
  4340. * except UnicodeEncodeError as ue:
  4341. */
  4342. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_writer, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  4343. __Pyx_GOTREF(__pyx_t_2);
  4344. __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  4345. __Pyx_GOTREF(__pyx_t_1);
  4346. __Pyx_INCREF(__pyx_v_text);
  4347. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_text);
  4348. __Pyx_GIVEREF(__pyx_v_text);
  4349. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  4350. __Pyx_GOTREF(__pyx_t_3);
  4351. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4352. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4353. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4354. }
  4355. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  4356. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  4357. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  4358. goto __pyx_L25_try_end;
  4359. __pyx_L18_error:;
  4360. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  4361. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  4362. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  4363. /* "lib/Naked/toolshed/c/file.pyx":148
  4364. * if not os.path.exists(self.filepath): # if the file does not exist, then can write
  4365. * try:
  4366. * with open(self.filepath, 'wt') as writer: # <<<<<<<<<<<<<<
  4367. * writer.write(text)
  4368. * return True
  4369. */
  4370. /*except:*/ {
  4371. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.safe_write", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4372. if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  4373. __Pyx_GOTREF(__pyx_t_3);
  4374. __Pyx_GOTREF(__pyx_t_1);
  4375. __Pyx_GOTREF(__pyx_t_2);
  4376. __pyx_t_13 = PyTuple_Pack(3, __pyx_t_3, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  4377. __Pyx_GOTREF(__pyx_t_13);
  4378. __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_13, NULL);
  4379. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4380. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4381. if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  4382. __Pyx_GOTREF(__pyx_t_14);
  4383. __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_14);
  4384. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  4385. if (__pyx_t_5 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  4386. __pyx_t_4 = ((!(__pyx_t_5 != 0)) != 0);
  4387. if (__pyx_t_4) {
  4388. __Pyx_GIVEREF(__pyx_t_3);
  4389. __Pyx_GIVEREF(__pyx_t_1);
  4390. __Pyx_XGIVEREF(__pyx_t_2);
  4391. __Pyx_ErrRestore(__pyx_t_3, __pyx_t_1, __pyx_t_2);
  4392. __pyx_t_3 = 0; __pyx_t_1 = 0; __pyx_t_2 = 0;
  4393. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  4394. }
  4395. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4396. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4397. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4398. goto __pyx_L19_exception_handled;
  4399. }
  4400. __pyx_L20_except_error:;
  4401. __Pyx_XGIVEREF(__pyx_t_10);
  4402. __Pyx_XGIVEREF(__pyx_t_11);
  4403. __Pyx_XGIVEREF(__pyx_t_12);
  4404. __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
  4405. goto __pyx_L4_error;
  4406. __pyx_L19_exception_handled:;
  4407. __Pyx_XGIVEREF(__pyx_t_10);
  4408. __Pyx_XGIVEREF(__pyx_t_11);
  4409. __Pyx_XGIVEREF(__pyx_t_12);
  4410. __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
  4411. __pyx_L25_try_end:;
  4412. }
  4413. }
  4414. /*finally:*/ {
  4415. /*normal exit:*/{
  4416. if (__pyx_t_9) {
  4417. __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__19, NULL);
  4418. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4419. if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
  4420. __Pyx_GOTREF(__pyx_t_12);
  4421. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4422. }
  4423. goto __pyx_L17;
  4424. }
  4425. __pyx_L17:;
  4426. }
  4427. goto __pyx_L30;
  4428. __pyx_L12_error:;
  4429. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4430. goto __pyx_L4_error;
  4431. __pyx_L30:;
  4432. }
  4433. /* "lib/Naked/toolshed/c/file.pyx":150
  4434. * with open(self.filepath, 'wt') as writer:
  4435. * writer.write(text)
  4436. * return True # <<<<<<<<<<<<<<
  4437. * except UnicodeEncodeError as ue:
  4438. * self.write_utf8(text)
  4439. */
  4440. __Pyx_XDECREF(__pyx_r);
  4441. __Pyx_INCREF(Py_True);
  4442. __pyx_r = Py_True;
  4443. goto __pyx_L8_try_return;
  4444. }
  4445. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  4446. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  4447. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  4448. goto __pyx_L11_try_end;
  4449. __pyx_L4_error:;
  4450. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  4451. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  4452. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  4453. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  4454. /* "lib/Naked/toolshed/c/file.pyx":151
  4455. * writer.write(text)
  4456. * return True
  4457. * except UnicodeEncodeError as ue: # <<<<<<<<<<<<<<
  4458. * self.write_utf8(text)
  4459. * return True
  4460. */
  4461. __pyx_t_15 = PyErr_ExceptionMatches(__pyx_builtin_UnicodeEncodeError);
  4462. if (__pyx_t_15) {
  4463. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.safe_write", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4464. if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
  4465. __Pyx_GOTREF(__pyx_t_2);
  4466. __Pyx_GOTREF(__pyx_t_1);
  4467. __Pyx_GOTREF(__pyx_t_3);
  4468. __Pyx_INCREF(__pyx_t_1);
  4469. __pyx_v_ue = __pyx_t_1;
  4470. /* "lib/Naked/toolshed/c/file.pyx":152
  4471. * return True
  4472. * except UnicodeEncodeError as ue:
  4473. * self.write_utf8(text) # <<<<<<<<<<<<<<
  4474. * return True
  4475. * except Exception as e:
  4476. */
  4477. __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_write_utf8); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
  4478. __Pyx_GOTREF(__pyx_t_13);
  4479. __pyx_t_16 = PyTuple_New(1); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
  4480. __Pyx_GOTREF(__pyx_t_16);
  4481. __Pyx_INCREF(__pyx_v_text);
  4482. PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_v_text);
  4483. __Pyx_GIVEREF(__pyx_v_text);
  4484. __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_16, NULL); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
  4485. __Pyx_GOTREF(__pyx_t_17);
  4486. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4487. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  4488. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  4489. /* "lib/Naked/toolshed/c/file.pyx":153
  4490. * except UnicodeEncodeError as ue:
  4491. * self.write_utf8(text)
  4492. * return True # <<<<<<<<<<<<<<
  4493. * except Exception as e:
  4494. * if DEBUG_FLAG:
  4495. */
  4496. __Pyx_XDECREF(__pyx_r);
  4497. __Pyx_INCREF(Py_True);
  4498. __pyx_r = Py_True;
  4499. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4500. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4501. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4502. goto __pyx_L7_except_return;
  4503. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4504. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4505. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4506. goto __pyx_L5_exception_handled;
  4507. }
  4508. /* "lib/Naked/toolshed/c/file.pyx":154
  4509. * self.write_utf8(text)
  4510. * return True
  4511. * except Exception as e: # <<<<<<<<<<<<<<
  4512. * if DEBUG_FLAG:
  4513. * sys.stderr.write("Naked Framework Error: Unable to write to requested file with the safe_write() method (Naked.toolshed.file.py).")
  4514. */
  4515. __pyx_t_15 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  4516. if (__pyx_t_15) {
  4517. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.safe_write", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4518. if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
  4519. __Pyx_GOTREF(__pyx_t_3);
  4520. __Pyx_GOTREF(__pyx_t_1);
  4521. __Pyx_GOTREF(__pyx_t_2);
  4522. __Pyx_INCREF(__pyx_t_1);
  4523. __pyx_v_e = __pyx_t_1;
  4524. /* "lib/Naked/toolshed/c/file.pyx":155
  4525. * return True
  4526. * except Exception as e:
  4527. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  4528. * sys.stderr.write("Naked Framework Error: Unable to write to requested file with the safe_write() method (Naked.toolshed.file.py).")
  4529. * raise e
  4530. */
  4531. __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
  4532. __Pyx_GOTREF(__pyx_t_17);
  4533. __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_17); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
  4534. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  4535. if (__pyx_t_4) {
  4536. /* "lib/Naked/toolshed/c/file.pyx":156
  4537. * except Exception as e:
  4538. * if DEBUG_FLAG:
  4539. * sys.stderr.write("Naked Framework Error: Unable to write to requested file with the safe_write() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  4540. * raise e
  4541. * else:
  4542. */
  4543. __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
  4544. __Pyx_GOTREF(__pyx_t_17);
  4545. __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_stderr); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
  4546. __Pyx_GOTREF(__pyx_t_16);
  4547. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  4548. __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_write); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
  4549. __Pyx_GOTREF(__pyx_t_17);
  4550. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  4551. __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
  4552. __Pyx_GOTREF(__pyx_t_16);
  4553. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  4554. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  4555. goto __pyx_L35;
  4556. }
  4557. __pyx_L35:;
  4558. /* "lib/Naked/toolshed/c/file.pyx":157
  4559. * if DEBUG_FLAG:
  4560. * sys.stderr.write("Naked Framework Error: Unable to write to requested file with the safe_write() method (Naked.toolshed.file.py).")
  4561. * raise e # <<<<<<<<<<<<<<
  4562. * else:
  4563. * return False # if file exists, do not write and return False
  4564. */
  4565. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  4566. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
  4567. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4568. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4569. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4570. goto __pyx_L5_exception_handled;
  4571. }
  4572. goto __pyx_L6_except_error;
  4573. __pyx_L6_except_error:;
  4574. __Pyx_XGIVEREF(__pyx_t_6);
  4575. __Pyx_XGIVEREF(__pyx_t_7);
  4576. __Pyx_XGIVEREF(__pyx_t_8);
  4577. __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
  4578. goto __pyx_L1_error;
  4579. __pyx_L8_try_return:;
  4580. __Pyx_XGIVEREF(__pyx_t_6);
  4581. __Pyx_XGIVEREF(__pyx_t_7);
  4582. __Pyx_XGIVEREF(__pyx_t_8);
  4583. __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
  4584. goto __pyx_L0;
  4585. __pyx_L7_except_return:;
  4586. __Pyx_XGIVEREF(__pyx_t_6);
  4587. __Pyx_XGIVEREF(__pyx_t_7);
  4588. __Pyx_XGIVEREF(__pyx_t_8);
  4589. __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
  4590. goto __pyx_L0;
  4591. __pyx_L5_exception_handled:;
  4592. __Pyx_XGIVEREF(__pyx_t_6);
  4593. __Pyx_XGIVEREF(__pyx_t_7);
  4594. __Pyx_XGIVEREF(__pyx_t_8);
  4595. __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
  4596. __pyx_L11_try_end:;
  4597. }
  4598. }
  4599. /*else*/ {
  4600. /* "lib/Naked/toolshed/c/file.pyx":159
  4601. * raise e
  4602. * else:
  4603. * return False # if file exists, do not write and return False # <<<<<<<<<<<<<<
  4604. *
  4605. * #------------------------------------------------------------------------------
  4606. */
  4607. __Pyx_XDECREF(__pyx_r);
  4608. __Pyx_INCREF(Py_False);
  4609. __pyx_r = Py_False;
  4610. goto __pyx_L0;
  4611. }
  4612. /* "lib/Naked/toolshed/c/file.pyx":144
  4613. * # Tests: test_IO.py :: test_file_ascii_safewrite, test_file_utf8_safewrite
  4614. * #------------------------------------------------------------------------------
  4615. * def safe_write(self, text): # <<<<<<<<<<<<<<
  4616. * import os.path
  4617. * if not os.path.exists(self.filepath): # if the file does not exist, then can write
  4618. */
  4619. /* function exit code */
  4620. __pyx_L1_error:;
  4621. __Pyx_XDECREF(__pyx_t_1);
  4622. __Pyx_XDECREF(__pyx_t_2);
  4623. __Pyx_XDECREF(__pyx_t_3);
  4624. __Pyx_XDECREF(__pyx_t_13);
  4625. __Pyx_XDECREF(__pyx_t_16);
  4626. __Pyx_XDECREF(__pyx_t_17);
  4627. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.safe_write", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4628. __pyx_r = NULL;
  4629. __pyx_L0:;
  4630. __Pyx_XDECREF(__pyx_v_os);
  4631. __Pyx_XDECREF(__pyx_v_writer);
  4632. __Pyx_XDECREF(__pyx_v_ue);
  4633. __Pyx_XDECREF(__pyx_v_e);
  4634. __Pyx_XGIVEREF(__pyx_r);
  4635. __Pyx_RefNannyFinishContext();
  4636. return __pyx_r;
  4637. }
  4638. /* "lib/Naked/toolshed/c/file.pyx":166
  4639. * # returns boolean indicator for success of write based upon test for existence of file (False = write failed because file exists)
  4640. * #------------------------------------------------------------------------------
  4641. * def safe_write_bin(self, file_data): # <<<<<<<<<<<<<<
  4642. * try:
  4643. * import os.path
  4644. */
  4645. /* Python wrapper */
  4646. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_17safe_write_bin(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  4647. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_17safe_write_bin = {__Pyx_NAMESTR("safe_write_bin"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_17safe_write_bin, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  4648. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_17safe_write_bin(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  4649. PyObject *__pyx_v_self = 0;
  4650. PyObject *__pyx_v_file_data = 0;
  4651. int __pyx_lineno = 0;
  4652. const char *__pyx_filename = NULL;
  4653. int __pyx_clineno = 0;
  4654. PyObject *__pyx_r = 0;
  4655. __Pyx_RefNannyDeclarations
  4656. __Pyx_RefNannySetupContext("safe_write_bin (wrapper)", 0);
  4657. {
  4658. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_file_data,0};
  4659. PyObject* values[2] = {0,0};
  4660. if (unlikely(__pyx_kwds)) {
  4661. Py_ssize_t kw_args;
  4662. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  4663. switch (pos_args) {
  4664. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  4665. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  4666. case 0: break;
  4667. default: goto __pyx_L5_argtuple_error;
  4668. }
  4669. kw_args = PyDict_Size(__pyx_kwds);
  4670. switch (pos_args) {
  4671. case 0:
  4672. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
  4673. else goto __pyx_L5_argtuple_error;
  4674. case 1:
  4675. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_file_data)) != 0)) kw_args--;
  4676. else {
  4677. __Pyx_RaiseArgtupleInvalid("safe_write_bin", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4678. }
  4679. }
  4680. if (unlikely(kw_args > 0)) {
  4681. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "safe_write_bin") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4682. }
  4683. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  4684. goto __pyx_L5_argtuple_error;
  4685. } else {
  4686. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  4687. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  4688. }
  4689. __pyx_v_self = values[0];
  4690. __pyx_v_file_data = values[1];
  4691. }
  4692. goto __pyx_L4_argument_unpacking_done;
  4693. __pyx_L5_argtuple_error:;
  4694. __Pyx_RaiseArgtupleInvalid("safe_write_bin", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4695. __pyx_L3_error:;
  4696. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.safe_write_bin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4697. __Pyx_RefNannyFinishContext();
  4698. return NULL;
  4699. __pyx_L4_argument_unpacking_done:;
  4700. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_16safe_write_bin(__pyx_self, __pyx_v_self, __pyx_v_file_data);
  4701. /* function exit code */
  4702. __Pyx_RefNannyFinishContext();
  4703. return __pyx_r;
  4704. }
  4705. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_16safe_write_bin(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_file_data) {
  4706. PyObject *__pyx_v_os = NULL;
  4707. PyObject *__pyx_v_writer = NULL;
  4708. PyObject *__pyx_v_e = NULL;
  4709. PyObject *__pyx_r = NULL;
  4710. __Pyx_RefNannyDeclarations
  4711. PyObject *__pyx_t_1 = NULL;
  4712. PyObject *__pyx_t_2 = NULL;
  4713. PyObject *__pyx_t_3 = NULL;
  4714. PyObject *__pyx_t_4 = NULL;
  4715. PyObject *__pyx_t_5 = NULL;
  4716. PyObject *__pyx_t_6 = NULL;
  4717. int __pyx_t_7;
  4718. int __pyx_t_8;
  4719. PyObject *__pyx_t_9 = NULL;
  4720. PyObject *__pyx_t_10 = NULL;
  4721. PyObject *__pyx_t_11 = NULL;
  4722. PyObject *__pyx_t_12 = NULL;
  4723. PyObject *__pyx_t_13 = NULL;
  4724. PyObject *__pyx_t_14 = NULL;
  4725. int __pyx_t_15;
  4726. PyObject *__pyx_t_16 = NULL;
  4727. int __pyx_lineno = 0;
  4728. const char *__pyx_filename = NULL;
  4729. int __pyx_clineno = 0;
  4730. __Pyx_RefNannySetupContext("safe_write_bin", 0);
  4731. /* "lib/Naked/toolshed/c/file.pyx":167
  4732. * #------------------------------------------------------------------------------
  4733. * def safe_write_bin(self, file_data):
  4734. * try: # <<<<<<<<<<<<<<
  4735. * import os.path
  4736. * if not os.path.exists(self.filepath):
  4737. */
  4738. {
  4739. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  4740. __Pyx_XGOTREF(__pyx_t_1);
  4741. __Pyx_XGOTREF(__pyx_t_2);
  4742. __Pyx_XGOTREF(__pyx_t_3);
  4743. /*try:*/ {
  4744. /* "lib/Naked/toolshed/c/file.pyx":168
  4745. * def safe_write_bin(self, file_data):
  4746. * try:
  4747. * import os.path # <<<<<<<<<<<<<<
  4748. * if not os.path.exists(self.filepath):
  4749. * with open(self.filepath, 'wb') as writer:
  4750. */
  4751. __pyx_t_4 = __Pyx_Import(__pyx_n_s_os_path, 0, -1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4752. __Pyx_GOTREF(__pyx_t_4);
  4753. __pyx_v_os = __pyx_t_4;
  4754. __pyx_t_4 = 0;
  4755. /* "lib/Naked/toolshed/c/file.pyx":169
  4756. * try:
  4757. * import os.path
  4758. * if not os.path.exists(self.filepath): # <<<<<<<<<<<<<<
  4759. * with open(self.filepath, 'wb') as writer:
  4760. * writer.write(file_data)
  4761. */
  4762. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_os, __pyx_n_s_path); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4763. __Pyx_GOTREF(__pyx_t_4);
  4764. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_exists); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4765. __Pyx_GOTREF(__pyx_t_5);
  4766. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4767. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4768. __Pyx_GOTREF(__pyx_t_4);
  4769. __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4770. __Pyx_GOTREF(__pyx_t_6);
  4771. PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
  4772. __Pyx_GIVEREF(__pyx_t_4);
  4773. __pyx_t_4 = 0;
  4774. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4775. __Pyx_GOTREF(__pyx_t_4);
  4776. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4777. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4778. __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4779. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4780. __pyx_t_8 = ((!__pyx_t_7) != 0);
  4781. if (__pyx_t_8) {
  4782. /* "lib/Naked/toolshed/c/file.pyx":170
  4783. * import os.path
  4784. * if not os.path.exists(self.filepath):
  4785. * with open(self.filepath, 'wb') as writer: # <<<<<<<<<<<<<<
  4786. * writer.write(file_data)
  4787. * return True
  4788. */
  4789. /*with:*/ {
  4790. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4791. __Pyx_GOTREF(__pyx_t_4);
  4792. __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4793. __Pyx_GOTREF(__pyx_t_6);
  4794. PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
  4795. __Pyx_GIVEREF(__pyx_t_4);
  4796. __Pyx_INCREF(__pyx_n_s_wb);
  4797. PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_wb);
  4798. __Pyx_GIVEREF(__pyx_n_s_wb);
  4799. __pyx_t_4 = 0;
  4800. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4801. __Pyx_GOTREF(__pyx_t_4);
  4802. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4803. __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_n_s_exit); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4804. __Pyx_GOTREF(__pyx_t_9);
  4805. __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_n_s_enter); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
  4806. __Pyx_GOTREF(__pyx_t_6);
  4807. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
  4808. __Pyx_GOTREF(__pyx_t_5);
  4809. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4810. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4811. /*try:*/ {
  4812. {
  4813. __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
  4814. __Pyx_XGOTREF(__pyx_t_10);
  4815. __Pyx_XGOTREF(__pyx_t_11);
  4816. __Pyx_XGOTREF(__pyx_t_12);
  4817. /*try:*/ {
  4818. __Pyx_INCREF(__pyx_t_5);
  4819. __pyx_v_writer = __pyx_t_5;
  4820. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4821. /* "lib/Naked/toolshed/c/file.pyx":171
  4822. * if not os.path.exists(self.filepath):
  4823. * with open(self.filepath, 'wb') as writer:
  4824. * writer.write(file_data) # <<<<<<<<<<<<<<
  4825. * return True
  4826. * else:
  4827. */
  4828. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_writer, __pyx_n_s_write); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  4829. __Pyx_GOTREF(__pyx_t_5);
  4830. __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  4831. __Pyx_GOTREF(__pyx_t_4);
  4832. __Pyx_INCREF(__pyx_v_file_data);
  4833. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_file_data);
  4834. __Pyx_GIVEREF(__pyx_v_file_data);
  4835. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  4836. __Pyx_GOTREF(__pyx_t_6);
  4837. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4838. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4839. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4840. }
  4841. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  4842. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  4843. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  4844. goto __pyx_L25_try_end;
  4845. __pyx_L18_error:;
  4846. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4847. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  4848. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  4849. /* "lib/Naked/toolshed/c/file.pyx":170
  4850. * import os.path
  4851. * if not os.path.exists(self.filepath):
  4852. * with open(self.filepath, 'wb') as writer: # <<<<<<<<<<<<<<
  4853. * writer.write(file_data)
  4854. * return True
  4855. */
  4856. /*except:*/ {
  4857. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.safe_write_bin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4858. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_4, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  4859. __Pyx_GOTREF(__pyx_t_6);
  4860. __Pyx_GOTREF(__pyx_t_4);
  4861. __Pyx_GOTREF(__pyx_t_5);
  4862. __pyx_t_13 = PyTuple_Pack(3, __pyx_t_6, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  4863. __Pyx_GOTREF(__pyx_t_13);
  4864. __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_13, NULL);
  4865. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4866. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4867. if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  4868. __Pyx_GOTREF(__pyx_t_14);
  4869. __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_14);
  4870. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  4871. if (__pyx_t_8 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  4872. __pyx_t_7 = ((!(__pyx_t_8 != 0)) != 0);
  4873. if (__pyx_t_7) {
  4874. __Pyx_GIVEREF(__pyx_t_6);
  4875. __Pyx_GIVEREF(__pyx_t_4);
  4876. __Pyx_XGIVEREF(__pyx_t_5);
  4877. __Pyx_ErrRestore(__pyx_t_6, __pyx_t_4, __pyx_t_5);
  4878. __pyx_t_6 = 0; __pyx_t_4 = 0; __pyx_t_5 = 0;
  4879. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  4880. }
  4881. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4882. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4883. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4884. goto __pyx_L19_exception_handled;
  4885. }
  4886. __pyx_L20_except_error:;
  4887. __Pyx_XGIVEREF(__pyx_t_10);
  4888. __Pyx_XGIVEREF(__pyx_t_11);
  4889. __Pyx_XGIVEREF(__pyx_t_12);
  4890. __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
  4891. goto __pyx_L3_error;
  4892. __pyx_L19_exception_handled:;
  4893. __Pyx_XGIVEREF(__pyx_t_10);
  4894. __Pyx_XGIVEREF(__pyx_t_11);
  4895. __Pyx_XGIVEREF(__pyx_t_12);
  4896. __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
  4897. __pyx_L25_try_end:;
  4898. }
  4899. }
  4900. /*finally:*/ {
  4901. /*normal exit:*/{
  4902. if (__pyx_t_9) {
  4903. __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__21, NULL);
  4904. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4905. if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4906. __Pyx_GOTREF(__pyx_t_12);
  4907. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4908. }
  4909. goto __pyx_L17;
  4910. }
  4911. __pyx_L17:;
  4912. }
  4913. goto __pyx_L30;
  4914. __pyx_L12_error:;
  4915. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4916. goto __pyx_L3_error;
  4917. __pyx_L30:;
  4918. }
  4919. /* "lib/Naked/toolshed/c/file.pyx":172
  4920. * with open(self.filepath, 'wb') as writer:
  4921. * writer.write(file_data)
  4922. * return True # <<<<<<<<<<<<<<
  4923. * else:
  4924. * return False
  4925. */
  4926. __Pyx_XDECREF(__pyx_r);
  4927. __Pyx_INCREF(Py_True);
  4928. __pyx_r = Py_True;
  4929. goto __pyx_L7_try_return;
  4930. }
  4931. /*else*/ {
  4932. /* "lib/Naked/toolshed/c/file.pyx":174
  4933. * return True
  4934. * else:
  4935. * return False # <<<<<<<<<<<<<<
  4936. * except Exception as e:
  4937. * if DEBUG_FLAG:
  4938. */
  4939. __Pyx_XDECREF(__pyx_r);
  4940. __Pyx_INCREF(Py_False);
  4941. __pyx_r = Py_False;
  4942. goto __pyx_L7_try_return;
  4943. }
  4944. }
  4945. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  4946. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  4947. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  4948. goto __pyx_L10_try_end;
  4949. __pyx_L3_error:;
  4950. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  4951. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  4952. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  4953. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4954. /* "lib/Naked/toolshed/c/file.pyx":175
  4955. * else:
  4956. * return False
  4957. * except Exception as e: # <<<<<<<<<<<<<<
  4958. * if DEBUG_FLAG:
  4959. * sys.stderr.write("Naked Framework Error: Unable to write to requested file with the safe_write_bin() method (Naked.toolshed.file.py).")
  4960. */
  4961. __pyx_t_15 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  4962. if (__pyx_t_15) {
  4963. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.safe_write_bin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4964. if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  4965. __Pyx_GOTREF(__pyx_t_5);
  4966. __Pyx_GOTREF(__pyx_t_4);
  4967. __Pyx_GOTREF(__pyx_t_6);
  4968. __Pyx_INCREF(__pyx_t_4);
  4969. __pyx_v_e = __pyx_t_4;
  4970. /* "lib/Naked/toolshed/c/file.pyx":176
  4971. * return False
  4972. * except Exception as e:
  4973. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  4974. * sys.stderr.write("Naked Framework Error: Unable to write to requested file with the safe_write_bin() method (Naked.toolshed.file.py).")
  4975. * raise e
  4976. */
  4977. __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  4978. __Pyx_GOTREF(__pyx_t_13);
  4979. __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  4980. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4981. if (__pyx_t_7) {
  4982. /* "lib/Naked/toolshed/c/file.pyx":177
  4983. * except Exception as e:
  4984. * if DEBUG_FLAG:
  4985. * sys.stderr.write("Naked Framework Error: Unable to write to requested file with the safe_write_bin() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  4986. * raise e
  4987. *
  4988. */
  4989. __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  4990. __Pyx_GOTREF(__pyx_t_13);
  4991. __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_stderr); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  4992. __Pyx_GOTREF(__pyx_t_16);
  4993. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4994. __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_write); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  4995. __Pyx_GOTREF(__pyx_t_13);
  4996. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  4997. __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  4998. __Pyx_GOTREF(__pyx_t_16);
  4999. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  5000. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  5001. goto __pyx_L33;
  5002. }
  5003. __pyx_L33:;
  5004. /* "lib/Naked/toolshed/c/file.pyx":178
  5005. * if DEBUG_FLAG:
  5006. * sys.stderr.write("Naked Framework Error: Unable to write to requested file with the safe_write_bin() method (Naked.toolshed.file.py).")
  5007. * raise e # <<<<<<<<<<<<<<
  5008. *
  5009. *
  5010. */
  5011. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  5012. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  5013. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5014. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5015. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5016. goto __pyx_L4_exception_handled;
  5017. }
  5018. goto __pyx_L5_except_error;
  5019. __pyx_L5_except_error:;
  5020. __Pyx_XGIVEREF(__pyx_t_1);
  5021. __Pyx_XGIVEREF(__pyx_t_2);
  5022. __Pyx_XGIVEREF(__pyx_t_3);
  5023. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  5024. goto __pyx_L1_error;
  5025. __pyx_L7_try_return:;
  5026. __Pyx_XGIVEREF(__pyx_t_1);
  5027. __Pyx_XGIVEREF(__pyx_t_2);
  5028. __Pyx_XGIVEREF(__pyx_t_3);
  5029. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  5030. goto __pyx_L0;
  5031. __pyx_L4_exception_handled:;
  5032. __Pyx_XGIVEREF(__pyx_t_1);
  5033. __Pyx_XGIVEREF(__pyx_t_2);
  5034. __Pyx_XGIVEREF(__pyx_t_3);
  5035. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  5036. __pyx_L10_try_end:;
  5037. }
  5038. /* "lib/Naked/toolshed/c/file.pyx":166
  5039. * # returns boolean indicator for success of write based upon test for existence of file (False = write failed because file exists)
  5040. * #------------------------------------------------------------------------------
  5041. * def safe_write_bin(self, file_data): # <<<<<<<<<<<<<<
  5042. * try:
  5043. * import os.path
  5044. */
  5045. /* function exit code */
  5046. __pyx_L1_error:;
  5047. __Pyx_XDECREF(__pyx_t_4);
  5048. __Pyx_XDECREF(__pyx_t_5);
  5049. __Pyx_XDECREF(__pyx_t_6);
  5050. __Pyx_XDECREF(__pyx_t_13);
  5051. __Pyx_XDECREF(__pyx_t_16);
  5052. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.safe_write_bin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5053. __pyx_r = NULL;
  5054. __pyx_L0:;
  5055. __Pyx_XDECREF(__pyx_v_os);
  5056. __Pyx_XDECREF(__pyx_v_writer);
  5057. __Pyx_XDECREF(__pyx_v_e);
  5058. __Pyx_XGIVEREF(__pyx_r);
  5059. __Pyx_RefNannyFinishContext();
  5060. return __pyx_r;
  5061. }
  5062. /* "lib/Naked/toolshed/c/file.pyx":188
  5063. * # Tests: test_IO.py :: test_file_utf8_readwrite, test_file_utf8_readwrite_raises_unicodeerror
  5064. * #------------------------------------------------------------------------------
  5065. * def write_utf8(self, text): # <<<<<<<<<<<<<<
  5066. * try:
  5067. * import codecs
  5068. */
  5069. /* Python wrapper */
  5070. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_19write_utf8(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5071. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_19write_utf8 = {__Pyx_NAMESTR("write_utf8"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_19write_utf8, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  5072. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileWriter_19write_utf8(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  5073. PyObject *__pyx_v_self = 0;
  5074. PyObject *__pyx_v_text = 0;
  5075. int __pyx_lineno = 0;
  5076. const char *__pyx_filename = NULL;
  5077. int __pyx_clineno = 0;
  5078. PyObject *__pyx_r = 0;
  5079. __Pyx_RefNannyDeclarations
  5080. __Pyx_RefNannySetupContext("write_utf8 (wrapper)", 0);
  5081. {
  5082. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_text,0};
  5083. PyObject* values[2] = {0,0};
  5084. if (unlikely(__pyx_kwds)) {
  5085. Py_ssize_t kw_args;
  5086. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  5087. switch (pos_args) {
  5088. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  5089. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5090. case 0: break;
  5091. default: goto __pyx_L5_argtuple_error;
  5092. }
  5093. kw_args = PyDict_Size(__pyx_kwds);
  5094. switch (pos_args) {
  5095. case 0:
  5096. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
  5097. else goto __pyx_L5_argtuple_error;
  5098. case 1:
  5099. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_text)) != 0)) kw_args--;
  5100. else {
  5101. __Pyx_RaiseArgtupleInvalid("write_utf8", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5102. }
  5103. }
  5104. if (unlikely(kw_args > 0)) {
  5105. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_utf8") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5106. }
  5107. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  5108. goto __pyx_L5_argtuple_error;
  5109. } else {
  5110. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5111. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  5112. }
  5113. __pyx_v_self = values[0];
  5114. __pyx_v_text = values[1];
  5115. }
  5116. goto __pyx_L4_argument_unpacking_done;
  5117. __pyx_L5_argtuple_error:;
  5118. __Pyx_RaiseArgtupleInvalid("write_utf8", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5119. __pyx_L3_error:;
  5120. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.write_utf8", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5121. __Pyx_RefNannyFinishContext();
  5122. return NULL;
  5123. __pyx_L4_argument_unpacking_done:;
  5124. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_18write_utf8(__pyx_self, __pyx_v_self, __pyx_v_text);
  5125. /* function exit code */
  5126. __Pyx_RefNannyFinishContext();
  5127. return __pyx_r;
  5128. }
  5129. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileWriter_18write_utf8(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_text) {
  5130. PyObject *__pyx_v_codecs = NULL;
  5131. PyObject *__pyx_v_f = NULL;
  5132. PyObject *__pyx_v_ioe = NULL;
  5133. PyObject *__pyx_v_unicodedata = NULL;
  5134. PyObject *__pyx_v_norm_text = NULL;
  5135. PyObject *__pyx_v_e = NULL;
  5136. PyObject *__pyx_r = NULL;
  5137. __Pyx_RefNannyDeclarations
  5138. PyObject *__pyx_t_1 = NULL;
  5139. PyObject *__pyx_t_2 = NULL;
  5140. PyObject *__pyx_t_3 = NULL;
  5141. PyObject *__pyx_t_4 = NULL;
  5142. PyObject *__pyx_t_5 = NULL;
  5143. PyObject *__pyx_t_6 = NULL;
  5144. PyObject *__pyx_t_7 = NULL;
  5145. int __pyx_t_8;
  5146. int __pyx_t_9;
  5147. PyObject *__pyx_t_10 = NULL;
  5148. int __pyx_t_11;
  5149. char const *__pyx_t_12;
  5150. PyObject *__pyx_t_13 = NULL;
  5151. PyObject *__pyx_t_14 = NULL;
  5152. PyObject *__pyx_t_15 = NULL;
  5153. int __pyx_lineno = 0;
  5154. const char *__pyx_filename = NULL;
  5155. int __pyx_clineno = 0;
  5156. __Pyx_RefNannySetupContext("write_utf8", 0);
  5157. /* "lib/Naked/toolshed/c/file.pyx":189
  5158. * #------------------------------------------------------------------------------
  5159. * def write_utf8(self, text):
  5160. * try: # <<<<<<<<<<<<<<
  5161. * import codecs
  5162. * f = codecs.open(self.filepath, encoding='utf_8', mode='w')
  5163. */
  5164. {
  5165. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  5166. __Pyx_XGOTREF(__pyx_t_1);
  5167. __Pyx_XGOTREF(__pyx_t_2);
  5168. __Pyx_XGOTREF(__pyx_t_3);
  5169. /*try:*/ {
  5170. /* "lib/Naked/toolshed/c/file.pyx":190
  5171. * def write_utf8(self, text):
  5172. * try:
  5173. * import codecs # <<<<<<<<<<<<<<
  5174. * f = codecs.open(self.filepath, encoding='utf_8', mode='w')
  5175. * except IOError as ioe:
  5176. */
  5177. __pyx_t_4 = __Pyx_Import(__pyx_n_s_codecs, 0, -1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5178. __Pyx_GOTREF(__pyx_t_4);
  5179. __pyx_v_codecs = __pyx_t_4;
  5180. __pyx_t_4 = 0;
  5181. /* "lib/Naked/toolshed/c/file.pyx":191
  5182. * try:
  5183. * import codecs
  5184. * f = codecs.open(self.filepath, encoding='utf_8', mode='w') # <<<<<<<<<<<<<<
  5185. * except IOError as ioe:
  5186. * if DEBUG_FLAG:
  5187. */
  5188. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_codecs, __pyx_n_s_open); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5189. __Pyx_GOTREF(__pyx_t_4);
  5190. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5191. __Pyx_GOTREF(__pyx_t_5);
  5192. __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5193. __Pyx_GOTREF(__pyx_t_6);
  5194. PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
  5195. __Pyx_GIVEREF(__pyx_t_5);
  5196. __pyx_t_5 = 0;
  5197. __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5198. __Pyx_GOTREF(__pyx_t_5);
  5199. if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_encoding, __pyx_n_s_utf_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5200. if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_mode, __pyx_n_s_w) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5201. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5202. __Pyx_GOTREF(__pyx_t_7);
  5203. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5204. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5205. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5206. __pyx_v_f = __pyx_t_7;
  5207. __pyx_t_7 = 0;
  5208. }
  5209. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  5210. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5211. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5212. goto __pyx_L10_try_end;
  5213. __pyx_L3_error:;
  5214. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5215. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  5216. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  5217. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  5218. /* "lib/Naked/toolshed/c/file.pyx":192
  5219. * import codecs
  5220. * f = codecs.open(self.filepath, encoding='utf_8', mode='w')
  5221. * except IOError as ioe: # <<<<<<<<<<<<<<
  5222. * if DEBUG_FLAG:
  5223. * sys.stderr.write("Naked Framework Error: Unable to open file for write with the write_utf8() method (Naked.toolshed.file.py).")
  5224. */
  5225. __pyx_t_8 = PyErr_ExceptionMatches(__pyx_builtin_IOError);
  5226. if (__pyx_t_8) {
  5227. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.write_utf8", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5228. if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_5, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  5229. __Pyx_GOTREF(__pyx_t_7);
  5230. __Pyx_GOTREF(__pyx_t_5);
  5231. __Pyx_GOTREF(__pyx_t_6);
  5232. __Pyx_INCREF(__pyx_t_5);
  5233. __pyx_v_ioe = __pyx_t_5;
  5234. /* "lib/Naked/toolshed/c/file.pyx":193
  5235. * f = codecs.open(self.filepath, encoding='utf_8', mode='w')
  5236. * except IOError as ioe:
  5237. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  5238. * sys.stderr.write("Naked Framework Error: Unable to open file for write with the write_utf8() method (Naked.toolshed.file.py).")
  5239. * raise ioe
  5240. */
  5241. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  5242. __Pyx_GOTREF(__pyx_t_4);
  5243. __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  5244. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5245. if (__pyx_t_9) {
  5246. /* "lib/Naked/toolshed/c/file.pyx":194
  5247. * except IOError as ioe:
  5248. * if DEBUG_FLAG:
  5249. * sys.stderr.write("Naked Framework Error: Unable to open file for write with the write_utf8() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  5250. * raise ioe
  5251. * try:
  5252. */
  5253. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  5254. __Pyx_GOTREF(__pyx_t_4);
  5255. __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_stderr); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  5256. __Pyx_GOTREF(__pyx_t_10);
  5257. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5258. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_write); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  5259. __Pyx_GOTREF(__pyx_t_4);
  5260. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  5261. __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  5262. __Pyx_GOTREF(__pyx_t_10);
  5263. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5264. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  5265. goto __pyx_L13;
  5266. }
  5267. __pyx_L13:;
  5268. /* "lib/Naked/toolshed/c/file.pyx":195
  5269. * if DEBUG_FLAG:
  5270. * sys.stderr.write("Naked Framework Error: Unable to open file for write with the write_utf8() method (Naked.toolshed.file.py).")
  5271. * raise ioe # <<<<<<<<<<<<<<
  5272. * try:
  5273. * import unicodedata
  5274. */
  5275. __Pyx_Raise(__pyx_v_ioe, 0, 0, 0);
  5276. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  5277. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5278. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5279. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5280. goto __pyx_L4_exception_handled;
  5281. }
  5282. goto __pyx_L5_except_error;
  5283. __pyx_L5_except_error:;
  5284. __Pyx_XGIVEREF(__pyx_t_1);
  5285. __Pyx_XGIVEREF(__pyx_t_2);
  5286. __Pyx_XGIVEREF(__pyx_t_3);
  5287. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  5288. goto __pyx_L1_error;
  5289. __pyx_L4_exception_handled:;
  5290. __Pyx_XGIVEREF(__pyx_t_1);
  5291. __Pyx_XGIVEREF(__pyx_t_2);
  5292. __Pyx_XGIVEREF(__pyx_t_3);
  5293. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  5294. __pyx_L10_try_end:;
  5295. }
  5296. /* "lib/Naked/toolshed/c/file.pyx":196
  5297. * sys.stderr.write("Naked Framework Error: Unable to open file for write with the write_utf8() method (Naked.toolshed.file.py).")
  5298. * raise ioe
  5299. * try: # <<<<<<<<<<<<<<
  5300. * import unicodedata
  5301. * norm_text = unicodedata.normalize('NFKD', text) # NKFD normalization of the unicode data before write
  5302. */
  5303. /*try:*/ {
  5304. {
  5305. __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1);
  5306. __Pyx_XGOTREF(__pyx_t_3);
  5307. __Pyx_XGOTREF(__pyx_t_2);
  5308. __Pyx_XGOTREF(__pyx_t_1);
  5309. /*try:*/ {
  5310. /* "lib/Naked/toolshed/c/file.pyx":197
  5311. * raise ioe
  5312. * try:
  5313. * import unicodedata # <<<<<<<<<<<<<<
  5314. * norm_text = unicodedata.normalize('NFKD', text) # NKFD normalization of the unicode data before write
  5315. * f.write(norm_text)
  5316. */
  5317. __pyx_t_6 = __Pyx_Import(__pyx_n_s_unicodedata, 0, -1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  5318. __Pyx_GOTREF(__pyx_t_6);
  5319. __pyx_v_unicodedata = __pyx_t_6;
  5320. __pyx_t_6 = 0;
  5321. /* "lib/Naked/toolshed/c/file.pyx":198
  5322. * try:
  5323. * import unicodedata
  5324. * norm_text = unicodedata.normalize('NFKD', text) # NKFD normalization of the unicode data before write # <<<<<<<<<<<<<<
  5325. * f.write(norm_text)
  5326. * except Exception as e:
  5327. */
  5328. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_unicodedata, __pyx_n_s_normalize); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  5329. __Pyx_GOTREF(__pyx_t_6);
  5330. __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  5331. __Pyx_GOTREF(__pyx_t_5);
  5332. __Pyx_INCREF(__pyx_n_s_NFKD);
  5333. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_NFKD);
  5334. __Pyx_GIVEREF(__pyx_n_s_NFKD);
  5335. __Pyx_INCREF(__pyx_v_text);
  5336. PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_text);
  5337. __Pyx_GIVEREF(__pyx_v_text);
  5338. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  5339. __Pyx_GOTREF(__pyx_t_7);
  5340. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5341. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5342. __pyx_v_norm_text = __pyx_t_7;
  5343. __pyx_t_7 = 0;
  5344. /* "lib/Naked/toolshed/c/file.pyx":199
  5345. * import unicodedata
  5346. * norm_text = unicodedata.normalize('NFKD', text) # NKFD normalization of the unicode data before write
  5347. * f.write(norm_text) # <<<<<<<<<<<<<<
  5348. * except Exception as e:
  5349. * if DEBUG_FLAG:
  5350. */
  5351. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_write); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  5352. __Pyx_GOTREF(__pyx_t_7);
  5353. __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  5354. __Pyx_GOTREF(__pyx_t_5);
  5355. __Pyx_INCREF(__pyx_v_norm_text);
  5356. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_norm_text);
  5357. __Pyx_GIVEREF(__pyx_v_norm_text);
  5358. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  5359. __Pyx_GOTREF(__pyx_t_6);
  5360. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5361. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5362. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5363. }
  5364. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5365. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5366. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  5367. goto __pyx_L24_try_end;
  5368. __pyx_L17_error:;
  5369. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5370. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  5371. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  5372. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  5373. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  5374. /* "lib/Naked/toolshed/c/file.pyx":200
  5375. * norm_text = unicodedata.normalize('NFKD', text) # NKFD normalization of the unicode data before write
  5376. * f.write(norm_text)
  5377. * except Exception as e: # <<<<<<<<<<<<<<
  5378. * if DEBUG_FLAG:
  5379. * sys.stderr.write("Naked Framework Error: Unable to write UTF-8 encoded text to file with the write_utf8() method (Naked.toolshed.file.py).")
  5380. */
  5381. __pyx_t_8 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  5382. if (__pyx_t_8) {
  5383. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.write_utf8", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5384. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  5385. __Pyx_GOTREF(__pyx_t_6);
  5386. __Pyx_GOTREF(__pyx_t_5);
  5387. __Pyx_GOTREF(__pyx_t_7);
  5388. __Pyx_INCREF(__pyx_t_5);
  5389. __pyx_v_e = __pyx_t_5;
  5390. /* "lib/Naked/toolshed/c/file.pyx":201
  5391. * f.write(norm_text)
  5392. * except Exception as e:
  5393. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  5394. * sys.stderr.write("Naked Framework Error: Unable to write UTF-8 encoded text to file with the write_utf8() method (Naked.toolshed.file.py).")
  5395. * raise e
  5396. */
  5397. __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  5398. __Pyx_GOTREF(__pyx_t_10);
  5399. __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  5400. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  5401. if (__pyx_t_9) {
  5402. /* "lib/Naked/toolshed/c/file.pyx":202
  5403. * except Exception as e:
  5404. * if DEBUG_FLAG:
  5405. * sys.stderr.write("Naked Framework Error: Unable to write UTF-8 encoded text to file with the write_utf8() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  5406. * raise e
  5407. * finally:
  5408. */
  5409. __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  5410. __Pyx_GOTREF(__pyx_t_10);
  5411. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_stderr); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  5412. __Pyx_GOTREF(__pyx_t_4);
  5413. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  5414. __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_write); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  5415. __Pyx_GOTREF(__pyx_t_10);
  5416. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5417. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  5418. __Pyx_GOTREF(__pyx_t_4);
  5419. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  5420. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5421. goto __pyx_L27;
  5422. }
  5423. __pyx_L27:;
  5424. /* "lib/Naked/toolshed/c/file.pyx":203
  5425. * if DEBUG_FLAG:
  5426. * sys.stderr.write("Naked Framework Error: Unable to write UTF-8 encoded text to file with the write_utf8() method (Naked.toolshed.file.py).")
  5427. * raise e # <<<<<<<<<<<<<<
  5428. * finally:
  5429. * f.close()
  5430. */
  5431. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  5432. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  5433. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5434. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5435. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5436. goto __pyx_L18_exception_handled;
  5437. }
  5438. goto __pyx_L19_except_error;
  5439. __pyx_L19_except_error:;
  5440. __Pyx_XGIVEREF(__pyx_t_3);
  5441. __Pyx_XGIVEREF(__pyx_t_2);
  5442. __Pyx_XGIVEREF(__pyx_t_1);
  5443. __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_2, __pyx_t_1);
  5444. goto __pyx_L15_error;
  5445. __pyx_L18_exception_handled:;
  5446. __Pyx_XGIVEREF(__pyx_t_3);
  5447. __Pyx_XGIVEREF(__pyx_t_2);
  5448. __Pyx_XGIVEREF(__pyx_t_1);
  5449. __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_2, __pyx_t_1);
  5450. __pyx_L24_try_end:;
  5451. }
  5452. }
  5453. /* "lib/Naked/toolshed/c/file.pyx":205
  5454. * raise e
  5455. * finally:
  5456. * f.close() # <<<<<<<<<<<<<<
  5457. *
  5458. * #------------------------------------------------------------------------------
  5459. */
  5460. /*finally:*/ {
  5461. /*normal exit:*/{
  5462. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_close); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5463. __Pyx_GOTREF(__pyx_t_7);
  5464. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5465. __Pyx_GOTREF(__pyx_t_5);
  5466. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5467. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5468. goto __pyx_L16;
  5469. }
  5470. /*exception exit:*/{
  5471. __pyx_L15_error:;
  5472. __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
  5473. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  5474. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5475. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  5476. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  5477. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  5478. if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
  5479. if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3) < 0)) __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  5480. __Pyx_XGOTREF(__pyx_t_1);
  5481. __Pyx_XGOTREF(__pyx_t_2);
  5482. __Pyx_XGOTREF(__pyx_t_3);
  5483. __Pyx_XGOTREF(__pyx_t_13);
  5484. __Pyx_XGOTREF(__pyx_t_14);
  5485. __Pyx_XGOTREF(__pyx_t_15);
  5486. __pyx_t_8 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_12 = __pyx_filename;
  5487. {
  5488. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_close); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L29_error;}
  5489. __Pyx_GOTREF(__pyx_t_5);
  5490. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L29_error;}
  5491. __Pyx_GOTREF(__pyx_t_7);
  5492. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5493. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5494. }
  5495. if (PY_MAJOR_VERSION >= 3) {
  5496. __Pyx_XGIVEREF(__pyx_t_13);
  5497. __Pyx_XGIVEREF(__pyx_t_14);
  5498. __Pyx_XGIVEREF(__pyx_t_15);
  5499. __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
  5500. }
  5501. __Pyx_XGIVEREF(__pyx_t_1);
  5502. __Pyx_XGIVEREF(__pyx_t_2);
  5503. __Pyx_XGIVEREF(__pyx_t_3);
  5504. __Pyx_ErrRestore(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  5505. __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
  5506. __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_12;
  5507. goto __pyx_L1_error;
  5508. __pyx_L29_error:;
  5509. if (PY_MAJOR_VERSION >= 3) {
  5510. __Pyx_XGIVEREF(__pyx_t_13);
  5511. __Pyx_XGIVEREF(__pyx_t_14);
  5512. __Pyx_XGIVEREF(__pyx_t_15);
  5513. __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
  5514. }
  5515. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  5516. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5517. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5518. __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
  5519. goto __pyx_L1_error;
  5520. }
  5521. __pyx_L16:;
  5522. }
  5523. /* "lib/Naked/toolshed/c/file.pyx":188
  5524. * # Tests: test_IO.py :: test_file_utf8_readwrite, test_file_utf8_readwrite_raises_unicodeerror
  5525. * #------------------------------------------------------------------------------
  5526. * def write_utf8(self, text): # <<<<<<<<<<<<<<
  5527. * try:
  5528. * import codecs
  5529. */
  5530. /* function exit code */
  5531. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  5532. goto __pyx_L0;
  5533. __pyx_L1_error:;
  5534. __Pyx_XDECREF(__pyx_t_4);
  5535. __Pyx_XDECREF(__pyx_t_5);
  5536. __Pyx_XDECREF(__pyx_t_6);
  5537. __Pyx_XDECREF(__pyx_t_7);
  5538. __Pyx_XDECREF(__pyx_t_10);
  5539. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileWriter.write_utf8", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5540. __pyx_r = NULL;
  5541. __pyx_L0:;
  5542. __Pyx_XDECREF(__pyx_v_codecs);
  5543. __Pyx_XDECREF(__pyx_v_f);
  5544. __Pyx_XDECREF(__pyx_v_ioe);
  5545. __Pyx_XDECREF(__pyx_v_unicodedata);
  5546. __Pyx_XDECREF(__pyx_v_norm_text);
  5547. __Pyx_XDECREF(__pyx_v_e);
  5548. __Pyx_XGIVEREF(__pyx_r);
  5549. __Pyx_RefNannyFinishContext();
  5550. return __pyx_r;
  5551. }
  5552. /* "lib/Naked/toolshed/c/file.pyx":213
  5553. * #------------------------------------------------------------------------------
  5554. * class FileReader(IO):
  5555. * def __init__(self, filepath): # <<<<<<<<<<<<<<
  5556. * IO.__init__(self, filepath)
  5557. *
  5558. */
  5559. /* Python wrapper */
  5560. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5561. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileReader_1__init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_1__init__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  5562. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  5563. PyObject *__pyx_v_self = 0;
  5564. PyObject *__pyx_v_filepath = 0;
  5565. int __pyx_lineno = 0;
  5566. const char *__pyx_filename = NULL;
  5567. int __pyx_clineno = 0;
  5568. PyObject *__pyx_r = 0;
  5569. __Pyx_RefNannyDeclarations
  5570. __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  5571. {
  5572. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_filepath,0};
  5573. PyObject* values[2] = {0,0};
  5574. if (unlikely(__pyx_kwds)) {
  5575. Py_ssize_t kw_args;
  5576. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  5577. switch (pos_args) {
  5578. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  5579. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5580. case 0: break;
  5581. default: goto __pyx_L5_argtuple_error;
  5582. }
  5583. kw_args = PyDict_Size(__pyx_kwds);
  5584. switch (pos_args) {
  5585. case 0:
  5586. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
  5587. else goto __pyx_L5_argtuple_error;
  5588. case 1:
  5589. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_filepath)) != 0)) kw_args--;
  5590. else {
  5591. __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5592. }
  5593. }
  5594. if (unlikely(kw_args > 0)) {
  5595. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5596. }
  5597. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  5598. goto __pyx_L5_argtuple_error;
  5599. } else {
  5600. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5601. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  5602. }
  5603. __pyx_v_self = values[0];
  5604. __pyx_v_filepath = values[1];
  5605. }
  5606. goto __pyx_L4_argument_unpacking_done;
  5607. __pyx_L5_argtuple_error:;
  5608. __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5609. __pyx_L3_error:;
  5610. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5611. __Pyx_RefNannyFinishContext();
  5612. return NULL;
  5613. __pyx_L4_argument_unpacking_done:;
  5614. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader___init__(__pyx_self, __pyx_v_self, __pyx_v_filepath);
  5615. /* function exit code */
  5616. __Pyx_RefNannyFinishContext();
  5617. return __pyx_r;
  5618. }
  5619. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_filepath) {
  5620. PyObject *__pyx_r = NULL;
  5621. __Pyx_RefNannyDeclarations
  5622. PyObject *__pyx_t_1 = NULL;
  5623. PyObject *__pyx_t_2 = NULL;
  5624. PyObject *__pyx_t_3 = NULL;
  5625. int __pyx_lineno = 0;
  5626. const char *__pyx_filename = NULL;
  5627. int __pyx_clineno = 0;
  5628. __Pyx_RefNannySetupContext("__init__", 0);
  5629. /* "lib/Naked/toolshed/c/file.pyx":214
  5630. * class FileReader(IO):
  5631. * def __init__(self, filepath):
  5632. * IO.__init__(self, filepath) # <<<<<<<<<<<<<<
  5633. *
  5634. * #------------------------------------------------------------------------------
  5635. */
  5636. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_IO); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5637. __Pyx_GOTREF(__pyx_t_1);
  5638. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5639. __Pyx_GOTREF(__pyx_t_2);
  5640. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5641. __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5642. __Pyx_GOTREF(__pyx_t_1);
  5643. __Pyx_INCREF(__pyx_v_self);
  5644. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
  5645. __Pyx_GIVEREF(__pyx_v_self);
  5646. __Pyx_INCREF(__pyx_v_filepath);
  5647. PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_filepath);
  5648. __Pyx_GIVEREF(__pyx_v_filepath);
  5649. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5650. __Pyx_GOTREF(__pyx_t_3);
  5651. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5652. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5653. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5654. /* "lib/Naked/toolshed/c/file.pyx":213
  5655. * #------------------------------------------------------------------------------
  5656. * class FileReader(IO):
  5657. * def __init__(self, filepath): # <<<<<<<<<<<<<<
  5658. * IO.__init__(self, filepath)
  5659. *
  5660. */
  5661. /* function exit code */
  5662. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  5663. goto __pyx_L0;
  5664. __pyx_L1_error:;
  5665. __Pyx_XDECREF(__pyx_t_1);
  5666. __Pyx_XDECREF(__pyx_t_2);
  5667. __Pyx_XDECREF(__pyx_t_3);
  5668. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5669. __pyx_r = NULL;
  5670. __pyx_L0:;
  5671. __Pyx_XGIVEREF(__pyx_r);
  5672. __Pyx_RefNannyFinishContext();
  5673. return __pyx_r;
  5674. }
  5675. /* "lib/Naked/toolshed/c/file.pyx":222
  5676. * # Tests: test_IO.py :: test_file_ascii_readwrite, test_file_read_missing_file,
  5677. * #------------------------------------------------------------------------------
  5678. * def read(self): # <<<<<<<<<<<<<<
  5679. * try:
  5680. * return self.read_utf8() #reads everything as unicode in utf8 encoding
  5681. */
  5682. /* Python wrapper */
  5683. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_3read(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
  5684. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileReader_3read = {__Pyx_NAMESTR("read"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_3read, METH_O, __Pyx_DOCSTR(0)};
  5685. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_3read(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  5686. PyObject *__pyx_r = 0;
  5687. __Pyx_RefNannyDeclarations
  5688. __Pyx_RefNannySetupContext("read (wrapper)", 0);
  5689. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_2read(__pyx_self, ((PyObject *)__pyx_v_self));
  5690. /* function exit code */
  5691. __Pyx_RefNannyFinishContext();
  5692. return __pyx_r;
  5693. }
  5694. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_2read(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  5695. PyObject *__pyx_v_e = NULL;
  5696. PyObject *__pyx_r = NULL;
  5697. __Pyx_RefNannyDeclarations
  5698. PyObject *__pyx_t_1 = NULL;
  5699. PyObject *__pyx_t_2 = NULL;
  5700. PyObject *__pyx_t_3 = NULL;
  5701. PyObject *__pyx_t_4 = NULL;
  5702. PyObject *__pyx_t_5 = NULL;
  5703. int __pyx_t_6;
  5704. PyObject *__pyx_t_7 = NULL;
  5705. PyObject *__pyx_t_8 = NULL;
  5706. int __pyx_t_9;
  5707. PyObject *__pyx_t_10 = NULL;
  5708. int __pyx_lineno = 0;
  5709. const char *__pyx_filename = NULL;
  5710. int __pyx_clineno = 0;
  5711. __Pyx_RefNannySetupContext("read", 0);
  5712. /* "lib/Naked/toolshed/c/file.pyx":223
  5713. * #------------------------------------------------------------------------------
  5714. * def read(self):
  5715. * try: # <<<<<<<<<<<<<<
  5716. * return self.read_utf8() #reads everything as unicode in utf8 encoding
  5717. * except Exception as e:
  5718. */
  5719. {
  5720. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  5721. __Pyx_XGOTREF(__pyx_t_1);
  5722. __Pyx_XGOTREF(__pyx_t_2);
  5723. __Pyx_XGOTREF(__pyx_t_3);
  5724. /*try:*/ {
  5725. /* "lib/Naked/toolshed/c/file.pyx":224
  5726. * def read(self):
  5727. * try:
  5728. * return self.read_utf8() #reads everything as unicode in utf8 encoding # <<<<<<<<<<<<<<
  5729. * except Exception as e:
  5730. * if DEBUG_FLAG:
  5731. */
  5732. __Pyx_XDECREF(__pyx_r);
  5733. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_read_utf8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5734. __Pyx_GOTREF(__pyx_t_4);
  5735. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5736. __Pyx_GOTREF(__pyx_t_5);
  5737. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5738. __pyx_r = __pyx_t_5;
  5739. __pyx_t_5 = 0;
  5740. goto __pyx_L7_try_return;
  5741. }
  5742. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  5743. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  5744. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5745. goto __pyx_L10_try_end;
  5746. __pyx_L3_error:;
  5747. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5748. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  5749. /* "lib/Naked/toolshed/c/file.pyx":225
  5750. * try:
  5751. * return self.read_utf8() #reads everything as unicode in utf8 encoding
  5752. * except Exception as e: # <<<<<<<<<<<<<<
  5753. * if DEBUG_FLAG:
  5754. * sys.stderr.write("Naked Framework Error: Unable to read text from the requested file with the read() method (Naked.toolshed.file.py).")
  5755. */
  5756. __pyx_t_6 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  5757. if (__pyx_t_6) {
  5758. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.read", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5759. if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  5760. __Pyx_GOTREF(__pyx_t_5);
  5761. __Pyx_GOTREF(__pyx_t_4);
  5762. __Pyx_GOTREF(__pyx_t_7);
  5763. __Pyx_INCREF(__pyx_t_4);
  5764. __pyx_v_e = __pyx_t_4;
  5765. /* "lib/Naked/toolshed/c/file.pyx":226
  5766. * return self.read_utf8() #reads everything as unicode in utf8 encoding
  5767. * except Exception as e:
  5768. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  5769. * sys.stderr.write("Naked Framework Error: Unable to read text from the requested file with the read() method (Naked.toolshed.file.py).")
  5770. * raise e
  5771. */
  5772. __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  5773. __Pyx_GOTREF(__pyx_t_8);
  5774. __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  5775. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5776. if (__pyx_t_9) {
  5777. /* "lib/Naked/toolshed/c/file.pyx":227
  5778. * except Exception as e:
  5779. * if DEBUG_FLAG:
  5780. * sys.stderr.write("Naked Framework Error: Unable to read text from the requested file with the read() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  5781. * raise e
  5782. *
  5783. */
  5784. __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  5785. __Pyx_GOTREF(__pyx_t_8);
  5786. __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_stderr); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  5787. __Pyx_GOTREF(__pyx_t_10);
  5788. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5789. __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_write); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  5790. __Pyx_GOTREF(__pyx_t_8);
  5791. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  5792. __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  5793. __Pyx_GOTREF(__pyx_t_10);
  5794. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5795. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  5796. goto __pyx_L13;
  5797. }
  5798. __pyx_L13:;
  5799. /* "lib/Naked/toolshed/c/file.pyx":228
  5800. * if DEBUG_FLAG:
  5801. * sys.stderr.write("Naked Framework Error: Unable to read text from the requested file with the read() method (Naked.toolshed.file.py).")
  5802. * raise e # <<<<<<<<<<<<<<
  5803. *
  5804. * #------------------------------------------------------------------------------
  5805. */
  5806. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  5807. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  5808. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5809. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5810. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5811. goto __pyx_L4_exception_handled;
  5812. }
  5813. goto __pyx_L5_except_error;
  5814. __pyx_L5_except_error:;
  5815. __Pyx_XGIVEREF(__pyx_t_1);
  5816. __Pyx_XGIVEREF(__pyx_t_2);
  5817. __Pyx_XGIVEREF(__pyx_t_3);
  5818. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  5819. goto __pyx_L1_error;
  5820. __pyx_L7_try_return:;
  5821. __Pyx_XGIVEREF(__pyx_t_1);
  5822. __Pyx_XGIVEREF(__pyx_t_2);
  5823. __Pyx_XGIVEREF(__pyx_t_3);
  5824. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  5825. goto __pyx_L0;
  5826. __pyx_L4_exception_handled:;
  5827. __Pyx_XGIVEREF(__pyx_t_1);
  5828. __Pyx_XGIVEREF(__pyx_t_2);
  5829. __Pyx_XGIVEREF(__pyx_t_3);
  5830. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  5831. __pyx_L10_try_end:;
  5832. }
  5833. /* "lib/Naked/toolshed/c/file.pyx":222
  5834. * # Tests: test_IO.py :: test_file_ascii_readwrite, test_file_read_missing_file,
  5835. * #------------------------------------------------------------------------------
  5836. * def read(self): # <<<<<<<<<<<<<<
  5837. * try:
  5838. * return self.read_utf8() #reads everything as unicode in utf8 encoding
  5839. */
  5840. /* function exit code */
  5841. __pyx_L1_error:;
  5842. __Pyx_XDECREF(__pyx_t_4);
  5843. __Pyx_XDECREF(__pyx_t_5);
  5844. __Pyx_XDECREF(__pyx_t_7);
  5845. __Pyx_XDECREF(__pyx_t_8);
  5846. __Pyx_XDECREF(__pyx_t_10);
  5847. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.read", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5848. __pyx_r = NULL;
  5849. __pyx_L0:;
  5850. __Pyx_XDECREF(__pyx_v_e);
  5851. __Pyx_XGIVEREF(__pyx_r);
  5852. __Pyx_RefNannyFinishContext();
  5853. return __pyx_r;
  5854. }
  5855. /* "lib/Naked/toolshed/c/file.pyx":236
  5856. * # Tests: test_IO.py :: test_file_bin_readwrite, test_file_read_bin_missing_file
  5857. * #------------------------------------------------------------------------------
  5858. * def read_bin(self): # <<<<<<<<<<<<<<
  5859. * try:
  5860. * with open(self.filepath, 'rb') as bin_reader:
  5861. */
  5862. /* Python wrapper */
  5863. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_5read_bin(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
  5864. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileReader_5read_bin = {__Pyx_NAMESTR("read_bin"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_5read_bin, METH_O, __Pyx_DOCSTR(0)};
  5865. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_5read_bin(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  5866. PyObject *__pyx_r = 0;
  5867. __Pyx_RefNannyDeclarations
  5868. __Pyx_RefNannySetupContext("read_bin (wrapper)", 0);
  5869. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_4read_bin(__pyx_self, ((PyObject *)__pyx_v_self));
  5870. /* function exit code */
  5871. __Pyx_RefNannyFinishContext();
  5872. return __pyx_r;
  5873. }
  5874. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_4read_bin(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  5875. PyObject *__pyx_v_bin_reader = NULL;
  5876. PyObject *__pyx_v_data = NULL;
  5877. PyObject *__pyx_v_e = NULL;
  5878. PyObject *__pyx_r = NULL;
  5879. __Pyx_RefNannyDeclarations
  5880. PyObject *__pyx_t_1 = NULL;
  5881. PyObject *__pyx_t_2 = NULL;
  5882. PyObject *__pyx_t_3 = NULL;
  5883. PyObject *__pyx_t_4 = NULL;
  5884. PyObject *__pyx_t_5 = NULL;
  5885. PyObject *__pyx_t_6 = NULL;
  5886. PyObject *__pyx_t_7 = NULL;
  5887. PyObject *__pyx_t_8 = NULL;
  5888. PyObject *__pyx_t_9 = NULL;
  5889. PyObject *__pyx_t_10 = NULL;
  5890. PyObject *__pyx_t_11 = NULL;
  5891. PyObject *__pyx_t_12 = NULL;
  5892. int __pyx_t_13;
  5893. int __pyx_t_14;
  5894. int __pyx_t_15;
  5895. PyObject *__pyx_t_16 = NULL;
  5896. int __pyx_lineno = 0;
  5897. const char *__pyx_filename = NULL;
  5898. int __pyx_clineno = 0;
  5899. __Pyx_RefNannySetupContext("read_bin", 0);
  5900. /* "lib/Naked/toolshed/c/file.pyx":237
  5901. * #------------------------------------------------------------------------------
  5902. * def read_bin(self):
  5903. * try: # <<<<<<<<<<<<<<
  5904. * with open(self.filepath, 'rb') as bin_reader:
  5905. * data = bin_reader.read()
  5906. */
  5907. {
  5908. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  5909. __Pyx_XGOTREF(__pyx_t_1);
  5910. __Pyx_XGOTREF(__pyx_t_2);
  5911. __Pyx_XGOTREF(__pyx_t_3);
  5912. /*try:*/ {
  5913. /* "lib/Naked/toolshed/c/file.pyx":238
  5914. * def read_bin(self):
  5915. * try:
  5916. * with open(self.filepath, 'rb') as bin_reader: # <<<<<<<<<<<<<<
  5917. * data = bin_reader.read()
  5918. * return data
  5919. */
  5920. /*with:*/ {
  5921. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5922. __Pyx_GOTREF(__pyx_t_4);
  5923. __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5924. __Pyx_GOTREF(__pyx_t_5);
  5925. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
  5926. __Pyx_GIVEREF(__pyx_t_4);
  5927. __Pyx_INCREF(__pyx_n_s_rb);
  5928. PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_n_s_rb);
  5929. __Pyx_GIVEREF(__pyx_n_s_rb);
  5930. __pyx_t_4 = 0;
  5931. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5932. __Pyx_GOTREF(__pyx_t_4);
  5933. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5934. __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_n_s_exit); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5935. __Pyx_GOTREF(__pyx_t_6);
  5936. __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_n_s_enter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
  5937. __Pyx_GOTREF(__pyx_t_5);
  5938. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
  5939. __Pyx_GOTREF(__pyx_t_7);
  5940. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5941. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5942. /*try:*/ {
  5943. {
  5944. __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
  5945. __Pyx_XGOTREF(__pyx_t_8);
  5946. __Pyx_XGOTREF(__pyx_t_9);
  5947. __Pyx_XGOTREF(__pyx_t_10);
  5948. /*try:*/ {
  5949. __Pyx_INCREF(__pyx_t_7);
  5950. __pyx_v_bin_reader = __pyx_t_7;
  5951. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5952. /* "lib/Naked/toolshed/c/file.pyx":239
  5953. * try:
  5954. * with open(self.filepath, 'rb') as bin_reader:
  5955. * data = bin_reader.read() # <<<<<<<<<<<<<<
  5956. * return data
  5957. * except Exception as e:
  5958. */
  5959. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_bin_reader, __pyx_n_s_read); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  5960. __Pyx_GOTREF(__pyx_t_7);
  5961. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  5962. __Pyx_GOTREF(__pyx_t_4);
  5963. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5964. __pyx_v_data = __pyx_t_4;
  5965. __pyx_t_4 = 0;
  5966. /* "lib/Naked/toolshed/c/file.pyx":240
  5967. * with open(self.filepath, 'rb') as bin_reader:
  5968. * data = bin_reader.read()
  5969. * return data # <<<<<<<<<<<<<<
  5970. * except Exception as e:
  5971. * if DEBUG_FLAG:
  5972. */
  5973. __Pyx_XDECREF(__pyx_r);
  5974. __Pyx_INCREF(__pyx_v_data);
  5975. __pyx_r = __pyx_v_data;
  5976. goto __pyx_L21_try_return;
  5977. }
  5978. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  5979. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  5980. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  5981. goto __pyx_L24_try_end;
  5982. __pyx_L17_error:;
  5983. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  5984. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  5985. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5986. /* "lib/Naked/toolshed/c/file.pyx":238
  5987. * def read_bin(self):
  5988. * try:
  5989. * with open(self.filepath, 'rb') as bin_reader: # <<<<<<<<<<<<<<
  5990. * data = bin_reader.read()
  5991. * return data
  5992. */
  5993. /*except:*/ {
  5994. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.read_bin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5995. if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_7, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  5996. __Pyx_GOTREF(__pyx_t_4);
  5997. __Pyx_GOTREF(__pyx_t_7);
  5998. __Pyx_GOTREF(__pyx_t_5);
  5999. __pyx_t_11 = PyTuple_Pack(3, __pyx_t_4, __pyx_t_7, __pyx_t_5); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  6000. __Pyx_GOTREF(__pyx_t_11);
  6001. __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_11, NULL);
  6002. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6003. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  6004. if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  6005. __Pyx_GOTREF(__pyx_t_12);
  6006. __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_12);
  6007. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  6008. if (__pyx_t_13 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  6009. __pyx_t_14 = ((!(__pyx_t_13 != 0)) != 0);
  6010. if (__pyx_t_14) {
  6011. __Pyx_GIVEREF(__pyx_t_4);
  6012. __Pyx_GIVEREF(__pyx_t_7);
  6013. __Pyx_XGIVEREF(__pyx_t_5);
  6014. __Pyx_ErrRestore(__pyx_t_4, __pyx_t_7, __pyx_t_5);
  6015. __pyx_t_4 = 0; __pyx_t_7 = 0; __pyx_t_5 = 0;
  6016. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  6017. }
  6018. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6019. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6020. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6021. goto __pyx_L18_exception_handled;
  6022. }
  6023. __pyx_L19_except_error:;
  6024. __Pyx_XGIVEREF(__pyx_t_8);
  6025. __Pyx_XGIVEREF(__pyx_t_9);
  6026. __Pyx_XGIVEREF(__pyx_t_10);
  6027. __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
  6028. goto __pyx_L3_error;
  6029. __pyx_L21_try_return:;
  6030. __Pyx_XGIVEREF(__pyx_t_8);
  6031. __Pyx_XGIVEREF(__pyx_t_9);
  6032. __Pyx_XGIVEREF(__pyx_t_10);
  6033. __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
  6034. goto __pyx_L14_return;
  6035. __pyx_L18_exception_handled:;
  6036. __Pyx_XGIVEREF(__pyx_t_8);
  6037. __Pyx_XGIVEREF(__pyx_t_9);
  6038. __Pyx_XGIVEREF(__pyx_t_10);
  6039. __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
  6040. __pyx_L24_try_end:;
  6041. }
  6042. }
  6043. /*finally:*/ {
  6044. /*normal exit:*/{
  6045. if (__pyx_t_6) {
  6046. __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__26, NULL);
  6047. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6048. if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6049. __Pyx_GOTREF(__pyx_t_10);
  6050. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  6051. }
  6052. goto __pyx_L16;
  6053. }
  6054. __pyx_L14_return: {
  6055. __pyx_t_10 = __pyx_r;
  6056. __pyx_r = 0;
  6057. if (__pyx_t_6) {
  6058. __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__27, NULL);
  6059. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6060. if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6061. __Pyx_GOTREF(__pyx_t_9);
  6062. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6063. }
  6064. __pyx_r = __pyx_t_10;
  6065. __pyx_t_10 = 0;
  6066. goto __pyx_L7_try_return;
  6067. }
  6068. __pyx_L16:;
  6069. }
  6070. goto __pyx_L29;
  6071. __pyx_L11_error:;
  6072. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6073. goto __pyx_L3_error;
  6074. __pyx_L29:;
  6075. }
  6076. }
  6077. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  6078. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  6079. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  6080. goto __pyx_L10_try_end;
  6081. __pyx_L3_error:;
  6082. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  6083. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  6084. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  6085. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  6086. /* "lib/Naked/toolshed/c/file.pyx":241
  6087. * data = bin_reader.read()
  6088. * return data
  6089. * except Exception as e: # <<<<<<<<<<<<<<
  6090. * if DEBUG_FLAG:
  6091. * sys.stderr.write("Naked Framework Error: Unable to read the binary data from the file with the read_bin method (Naked.toolshed.file.py).")
  6092. */
  6093. __pyx_t_15 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  6094. if (__pyx_t_15) {
  6095. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.read_bin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6096. if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_7, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6097. __Pyx_GOTREF(__pyx_t_5);
  6098. __Pyx_GOTREF(__pyx_t_7);
  6099. __Pyx_GOTREF(__pyx_t_4);
  6100. __Pyx_INCREF(__pyx_t_7);
  6101. __pyx_v_e = __pyx_t_7;
  6102. /* "lib/Naked/toolshed/c/file.pyx":242
  6103. * return data
  6104. * except Exception as e:
  6105. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  6106. * sys.stderr.write("Naked Framework Error: Unable to read the binary data from the file with the read_bin method (Naked.toolshed.file.py).")
  6107. * raise e
  6108. */
  6109. __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6110. __Pyx_GOTREF(__pyx_t_11);
  6111. __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6112. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  6113. if (__pyx_t_14) {
  6114. /* "lib/Naked/toolshed/c/file.pyx":243
  6115. * except Exception as e:
  6116. * if DEBUG_FLAG:
  6117. * sys.stderr.write("Naked Framework Error: Unable to read the binary data from the file with the read_bin method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  6118. * raise e
  6119. *
  6120. */
  6121. __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6122. __Pyx_GOTREF(__pyx_t_11);
  6123. __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_stderr); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6124. __Pyx_GOTREF(__pyx_t_16);
  6125. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  6126. __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_write); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6127. __Pyx_GOTREF(__pyx_t_11);
  6128. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  6129. __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6130. __Pyx_GOTREF(__pyx_t_16);
  6131. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  6132. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  6133. goto __pyx_L32;
  6134. }
  6135. __pyx_L32:;
  6136. /* "lib/Naked/toolshed/c/file.pyx":244
  6137. * if DEBUG_FLAG:
  6138. * sys.stderr.write("Naked Framework Error: Unable to read the binary data from the file with the read_bin method (Naked.toolshed.file.py).")
  6139. * raise e # <<<<<<<<<<<<<<
  6140. *
  6141. * #------------------------------------------------------------------------------
  6142. */
  6143. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  6144. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6145. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6146. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6147. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6148. goto __pyx_L4_exception_handled;
  6149. }
  6150. goto __pyx_L5_except_error;
  6151. __pyx_L5_except_error:;
  6152. __Pyx_XGIVEREF(__pyx_t_1);
  6153. __Pyx_XGIVEREF(__pyx_t_2);
  6154. __Pyx_XGIVEREF(__pyx_t_3);
  6155. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  6156. goto __pyx_L1_error;
  6157. __pyx_L7_try_return:;
  6158. __Pyx_XGIVEREF(__pyx_t_1);
  6159. __Pyx_XGIVEREF(__pyx_t_2);
  6160. __Pyx_XGIVEREF(__pyx_t_3);
  6161. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  6162. goto __pyx_L0;
  6163. __pyx_L4_exception_handled:;
  6164. __Pyx_XGIVEREF(__pyx_t_1);
  6165. __Pyx_XGIVEREF(__pyx_t_2);
  6166. __Pyx_XGIVEREF(__pyx_t_3);
  6167. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  6168. __pyx_L10_try_end:;
  6169. }
  6170. /* "lib/Naked/toolshed/c/file.pyx":236
  6171. * # Tests: test_IO.py :: test_file_bin_readwrite, test_file_read_bin_missing_file
  6172. * #------------------------------------------------------------------------------
  6173. * def read_bin(self): # <<<<<<<<<<<<<<
  6174. * try:
  6175. * with open(self.filepath, 'rb') as bin_reader:
  6176. */
  6177. /* function exit code */
  6178. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6179. goto __pyx_L0;
  6180. __pyx_L1_error:;
  6181. __Pyx_XDECREF(__pyx_t_4);
  6182. __Pyx_XDECREF(__pyx_t_5);
  6183. __Pyx_XDECREF(__pyx_t_7);
  6184. __Pyx_XDECREF(__pyx_t_11);
  6185. __Pyx_XDECREF(__pyx_t_16);
  6186. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.read_bin", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6187. __pyx_r = NULL;
  6188. __pyx_L0:;
  6189. __Pyx_XDECREF(__pyx_v_bin_reader);
  6190. __Pyx_XDECREF(__pyx_v_data);
  6191. __Pyx_XDECREF(__pyx_v_e);
  6192. __Pyx_XGIVEREF(__pyx_r);
  6193. __Pyx_RefNannyFinishContext();
  6194. return __pyx_r;
  6195. }
  6196. /* "lib/Naked/toolshed/c/file.pyx":252
  6197. * # Tests: test_IO.py :: test_file_utf8_readas_writeas, test_file_readas_missing_file
  6198. * #------------------------------------------------------------------------------
  6199. * def read_as(self, the_encoding): # <<<<<<<<<<<<<<
  6200. * try:
  6201. * if the_encoding == "":
  6202. */
  6203. /* Python wrapper */
  6204. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_7read_as(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  6205. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileReader_7read_as = {__Pyx_NAMESTR("read_as"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_7read_as, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  6206. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_7read_as(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  6207. PyObject *__pyx_v_self = 0;
  6208. PyObject *__pyx_v_the_encoding = 0;
  6209. int __pyx_lineno = 0;
  6210. const char *__pyx_filename = NULL;
  6211. int __pyx_clineno = 0;
  6212. PyObject *__pyx_r = 0;
  6213. __Pyx_RefNannyDeclarations
  6214. __Pyx_RefNannySetupContext("read_as (wrapper)", 0);
  6215. {
  6216. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_the_encoding,0};
  6217. PyObject* values[2] = {0,0};
  6218. if (unlikely(__pyx_kwds)) {
  6219. Py_ssize_t kw_args;
  6220. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  6221. switch (pos_args) {
  6222. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6223. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6224. case 0: break;
  6225. default: goto __pyx_L5_argtuple_error;
  6226. }
  6227. kw_args = PyDict_Size(__pyx_kwds);
  6228. switch (pos_args) {
  6229. case 0:
  6230. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
  6231. else goto __pyx_L5_argtuple_error;
  6232. case 1:
  6233. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_the_encoding)) != 0)) kw_args--;
  6234. else {
  6235. __Pyx_RaiseArgtupleInvalid("read_as", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6236. }
  6237. }
  6238. if (unlikely(kw_args > 0)) {
  6239. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read_as") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6240. }
  6241. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  6242. goto __pyx_L5_argtuple_error;
  6243. } else {
  6244. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6245. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6246. }
  6247. __pyx_v_self = values[0];
  6248. __pyx_v_the_encoding = values[1];
  6249. }
  6250. goto __pyx_L4_argument_unpacking_done;
  6251. __pyx_L5_argtuple_error:;
  6252. __Pyx_RaiseArgtupleInvalid("read_as", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6253. __pyx_L3_error:;
  6254. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.read_as", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6255. __Pyx_RefNannyFinishContext();
  6256. return NULL;
  6257. __pyx_L4_argument_unpacking_done:;
  6258. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_6read_as(__pyx_self, __pyx_v_self, __pyx_v_the_encoding);
  6259. /* function exit code */
  6260. __Pyx_RefNannyFinishContext();
  6261. return __pyx_r;
  6262. }
  6263. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_6read_as(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_the_encoding) {
  6264. PyObject *__pyx_v_codecs = NULL;
  6265. PyObject *__pyx_v_f = NULL;
  6266. PyObject *__pyx_v_data = NULL;
  6267. PyObject *__pyx_v_e = NULL;
  6268. PyObject *__pyx_r = NULL;
  6269. __Pyx_RefNannyDeclarations
  6270. PyObject *__pyx_t_1 = NULL;
  6271. PyObject *__pyx_t_2 = NULL;
  6272. PyObject *__pyx_t_3 = NULL;
  6273. int __pyx_t_4;
  6274. PyObject *__pyx_t_5 = NULL;
  6275. PyObject *__pyx_t_6 = NULL;
  6276. PyObject *__pyx_t_7 = NULL;
  6277. PyObject *__pyx_t_8 = NULL;
  6278. PyObject *__pyx_t_9 = NULL;
  6279. PyObject *__pyx_t_10 = NULL;
  6280. PyObject *__pyx_t_11 = NULL;
  6281. PyObject *__pyx_t_12 = NULL;
  6282. PyObject *__pyx_t_13 = NULL;
  6283. int __pyx_t_14;
  6284. int __pyx_t_15;
  6285. PyObject *__pyx_t_16 = NULL;
  6286. int __pyx_lineno = 0;
  6287. const char *__pyx_filename = NULL;
  6288. int __pyx_clineno = 0;
  6289. __Pyx_RefNannySetupContext("read_as", 0);
  6290. /* "lib/Naked/toolshed/c/file.pyx":253
  6291. * #------------------------------------------------------------------------------
  6292. * def read_as(self, the_encoding):
  6293. * try: # <<<<<<<<<<<<<<
  6294. * if the_encoding == "":
  6295. * raise RuntimeError("The text file encoding was not specified as an argument to the read_as method (Naked.toolshed.file.py:read_as).")
  6296. */
  6297. {
  6298. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  6299. __Pyx_XGOTREF(__pyx_t_1);
  6300. __Pyx_XGOTREF(__pyx_t_2);
  6301. __Pyx_XGOTREF(__pyx_t_3);
  6302. /*try:*/ {
  6303. /* "lib/Naked/toolshed/c/file.pyx":254
  6304. * def read_as(self, the_encoding):
  6305. * try:
  6306. * if the_encoding == "": # <<<<<<<<<<<<<<
  6307. * raise RuntimeError("The text file encoding was not specified as an argument to the read_as method (Naked.toolshed.file.py:read_as).")
  6308. * import codecs
  6309. */
  6310. __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_the_encoding, __pyx_kp_s__13, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6311. if (__pyx_t_4) {
  6312. /* "lib/Naked/toolshed/c/file.pyx":255
  6313. * try:
  6314. * if the_encoding == "":
  6315. * raise RuntimeError("The text file encoding was not specified as an argument to the read_as method (Naked.toolshed.file.py:read_as).") # <<<<<<<<<<<<<<
  6316. * import codecs
  6317. * with codecs.open(self.filepath, encoding=the_encoding, mode='r') as f:
  6318. */
  6319. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6320. __Pyx_GOTREF(__pyx_t_5);
  6321. __Pyx_Raise(__pyx_t_5, 0, 0, 0);
  6322. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6323. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6324. }
  6325. /* "lib/Naked/toolshed/c/file.pyx":256
  6326. * if the_encoding == "":
  6327. * raise RuntimeError("The text file encoding was not specified as an argument to the read_as method (Naked.toolshed.file.py:read_as).")
  6328. * import codecs # <<<<<<<<<<<<<<
  6329. * with codecs.open(self.filepath, encoding=the_encoding, mode='r') as f:
  6330. * data = f.read()
  6331. */
  6332. __pyx_t_5 = __Pyx_Import(__pyx_n_s_codecs, 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6333. __Pyx_GOTREF(__pyx_t_5);
  6334. __pyx_v_codecs = __pyx_t_5;
  6335. __pyx_t_5 = 0;
  6336. /* "lib/Naked/toolshed/c/file.pyx":257
  6337. * raise RuntimeError("The text file encoding was not specified as an argument to the read_as method (Naked.toolshed.file.py:read_as).")
  6338. * import codecs
  6339. * with codecs.open(self.filepath, encoding=the_encoding, mode='r') as f: # <<<<<<<<<<<<<<
  6340. * data = f.read()
  6341. * return data
  6342. */
  6343. /*with:*/ {
  6344. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_codecs, __pyx_n_s_open); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6345. __Pyx_GOTREF(__pyx_t_5);
  6346. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6347. __Pyx_GOTREF(__pyx_t_6);
  6348. __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6349. __Pyx_GOTREF(__pyx_t_7);
  6350. PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
  6351. __Pyx_GIVEREF(__pyx_t_6);
  6352. __pyx_t_6 = 0;
  6353. __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6354. __Pyx_GOTREF(__pyx_t_6);
  6355. if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_encoding, __pyx_v_the_encoding) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6356. if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_mode, __pyx_n_s_r) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6357. __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6358. __Pyx_GOTREF(__pyx_t_8);
  6359. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6360. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6361. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6362. __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_8, __pyx_n_s_exit); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6363. __Pyx_GOTREF(__pyx_t_9);
  6364. __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_8, __pyx_n_s_enter); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
  6365. __Pyx_GOTREF(__pyx_t_6);
  6366. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
  6367. __Pyx_GOTREF(__pyx_t_7);
  6368. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6369. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6370. /*try:*/ {
  6371. {
  6372. __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
  6373. __Pyx_XGOTREF(__pyx_t_10);
  6374. __Pyx_XGOTREF(__pyx_t_11);
  6375. __Pyx_XGOTREF(__pyx_t_12);
  6376. /*try:*/ {
  6377. __Pyx_INCREF(__pyx_t_7);
  6378. __pyx_v_f = __pyx_t_7;
  6379. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6380. /* "lib/Naked/toolshed/c/file.pyx":258
  6381. * import codecs
  6382. * with codecs.open(self.filepath, encoding=the_encoding, mode='r') as f:
  6383. * data = f.read() # <<<<<<<<<<<<<<
  6384. * return data
  6385. * except Exception as e:
  6386. */
  6387. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  6388. __Pyx_GOTREF(__pyx_t_7);
  6389. __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  6390. __Pyx_GOTREF(__pyx_t_8);
  6391. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6392. __pyx_v_data = __pyx_t_8;
  6393. __pyx_t_8 = 0;
  6394. }
  6395. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  6396. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  6397. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  6398. goto __pyx_L25_try_end;
  6399. __pyx_L18_error:;
  6400. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  6401. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  6402. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  6403. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  6404. /* "lib/Naked/toolshed/c/file.pyx":257
  6405. * raise RuntimeError("The text file encoding was not specified as an argument to the read_as method (Naked.toolshed.file.py:read_as).")
  6406. * import codecs
  6407. * with codecs.open(self.filepath, encoding=the_encoding, mode='r') as f: # <<<<<<<<<<<<<<
  6408. * data = f.read()
  6409. * return data
  6410. */
  6411. /*except:*/ {
  6412. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.read_as", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6413. if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  6414. __Pyx_GOTREF(__pyx_t_8);
  6415. __Pyx_GOTREF(__pyx_t_7);
  6416. __Pyx_GOTREF(__pyx_t_6);
  6417. __pyx_t_5 = PyTuple_Pack(3, __pyx_t_8, __pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  6418. __Pyx_GOTREF(__pyx_t_5);
  6419. __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_5, NULL);
  6420. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6421. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6422. if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  6423. __Pyx_GOTREF(__pyx_t_13);
  6424. __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_13);
  6425. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  6426. if (__pyx_t_4 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  6427. __pyx_t_14 = ((!(__pyx_t_4 != 0)) != 0);
  6428. if (__pyx_t_14) {
  6429. __Pyx_GIVEREF(__pyx_t_8);
  6430. __Pyx_GIVEREF(__pyx_t_7);
  6431. __Pyx_XGIVEREF(__pyx_t_6);
  6432. __Pyx_ErrRestore(__pyx_t_8, __pyx_t_7, __pyx_t_6);
  6433. __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_6 = 0;
  6434. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  6435. }
  6436. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6437. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6438. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6439. goto __pyx_L19_exception_handled;
  6440. }
  6441. __pyx_L20_except_error:;
  6442. __Pyx_XGIVEREF(__pyx_t_10);
  6443. __Pyx_XGIVEREF(__pyx_t_11);
  6444. __Pyx_XGIVEREF(__pyx_t_12);
  6445. __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
  6446. goto __pyx_L3_error;
  6447. __pyx_L19_exception_handled:;
  6448. __Pyx_XGIVEREF(__pyx_t_10);
  6449. __Pyx_XGIVEREF(__pyx_t_11);
  6450. __Pyx_XGIVEREF(__pyx_t_12);
  6451. __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
  6452. __pyx_L25_try_end:;
  6453. }
  6454. }
  6455. /*finally:*/ {
  6456. /*normal exit:*/{
  6457. if (__pyx_t_9) {
  6458. __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__30, NULL);
  6459. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6460. if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6461. __Pyx_GOTREF(__pyx_t_12);
  6462. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  6463. }
  6464. goto __pyx_L17;
  6465. }
  6466. __pyx_L17:;
  6467. }
  6468. goto __pyx_L30;
  6469. __pyx_L12_error:;
  6470. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6471. goto __pyx_L3_error;
  6472. __pyx_L30:;
  6473. }
  6474. /* "lib/Naked/toolshed/c/file.pyx":259
  6475. * with codecs.open(self.filepath, encoding=the_encoding, mode='r') as f:
  6476. * data = f.read()
  6477. * return data # <<<<<<<<<<<<<<
  6478. * except Exception as e:
  6479. * if DEBUG_FLAG:
  6480. */
  6481. __Pyx_XDECREF(__pyx_r);
  6482. if (unlikely(!__pyx_v_data)) { __Pyx_RaiseUnboundLocalError("data"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L3_error;} }
  6483. __Pyx_INCREF(__pyx_v_data);
  6484. __pyx_r = __pyx_v_data;
  6485. goto __pyx_L7_try_return;
  6486. }
  6487. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  6488. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  6489. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  6490. goto __pyx_L10_try_end;
  6491. __pyx_L3_error:;
  6492. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  6493. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  6494. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  6495. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  6496. /* "lib/Naked/toolshed/c/file.pyx":260
  6497. * data = f.read()
  6498. * return data
  6499. * except Exception as e: # <<<<<<<<<<<<<<
  6500. * if DEBUG_FLAG:
  6501. * sys.stderr.write("Naked Framework Error: Unable to read the file with the developer specified text encoding with the read_as method (Naked.toolshed.file.py).")
  6502. */
  6503. __pyx_t_15 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  6504. if (__pyx_t_15) {
  6505. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.read_as", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6506. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6507. __Pyx_GOTREF(__pyx_t_6);
  6508. __Pyx_GOTREF(__pyx_t_7);
  6509. __Pyx_GOTREF(__pyx_t_8);
  6510. __Pyx_INCREF(__pyx_t_7);
  6511. __pyx_v_e = __pyx_t_7;
  6512. /* "lib/Naked/toolshed/c/file.pyx":261
  6513. * return data
  6514. * except Exception as e:
  6515. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  6516. * sys.stderr.write("Naked Framework Error: Unable to read the file with the developer specified text encoding with the read_as method (Naked.toolshed.file.py).")
  6517. * raise e
  6518. */
  6519. __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6520. __Pyx_GOTREF(__pyx_t_5);
  6521. __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6522. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6523. if (__pyx_t_14) {
  6524. /* "lib/Naked/toolshed/c/file.pyx":262
  6525. * except Exception as e:
  6526. * if DEBUG_FLAG:
  6527. * sys.stderr.write("Naked Framework Error: Unable to read the file with the developer specified text encoding with the read_as method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  6528. * raise e
  6529. *
  6530. */
  6531. __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6532. __Pyx_GOTREF(__pyx_t_5);
  6533. __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_stderr); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6534. __Pyx_GOTREF(__pyx_t_16);
  6535. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6536. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_write); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6537. __Pyx_GOTREF(__pyx_t_5);
  6538. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  6539. __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6540. __Pyx_GOTREF(__pyx_t_16);
  6541. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6542. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  6543. goto __pyx_L33;
  6544. }
  6545. __pyx_L33:;
  6546. /* "lib/Naked/toolshed/c/file.pyx":263
  6547. * if DEBUG_FLAG:
  6548. * sys.stderr.write("Naked Framework Error: Unable to read the file with the developer specified text encoding with the read_as method (Naked.toolshed.file.py).")
  6549. * raise e # <<<<<<<<<<<<<<
  6550. *
  6551. * #------------------------------------------------------------------------------
  6552. */
  6553. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  6554. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6555. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6556. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6557. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6558. goto __pyx_L4_exception_handled;
  6559. }
  6560. goto __pyx_L5_except_error;
  6561. __pyx_L5_except_error:;
  6562. __Pyx_XGIVEREF(__pyx_t_1);
  6563. __Pyx_XGIVEREF(__pyx_t_2);
  6564. __Pyx_XGIVEREF(__pyx_t_3);
  6565. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  6566. goto __pyx_L1_error;
  6567. __pyx_L7_try_return:;
  6568. __Pyx_XGIVEREF(__pyx_t_1);
  6569. __Pyx_XGIVEREF(__pyx_t_2);
  6570. __Pyx_XGIVEREF(__pyx_t_3);
  6571. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  6572. goto __pyx_L0;
  6573. __pyx_L4_exception_handled:;
  6574. __Pyx_XGIVEREF(__pyx_t_1);
  6575. __Pyx_XGIVEREF(__pyx_t_2);
  6576. __Pyx_XGIVEREF(__pyx_t_3);
  6577. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  6578. __pyx_L10_try_end:;
  6579. }
  6580. /* "lib/Naked/toolshed/c/file.pyx":252
  6581. * # Tests: test_IO.py :: test_file_utf8_readas_writeas, test_file_readas_missing_file
  6582. * #------------------------------------------------------------------------------
  6583. * def read_as(self, the_encoding): # <<<<<<<<<<<<<<
  6584. * try:
  6585. * if the_encoding == "":
  6586. */
  6587. /* function exit code */
  6588. __pyx_L1_error:;
  6589. __Pyx_XDECREF(__pyx_t_5);
  6590. __Pyx_XDECREF(__pyx_t_6);
  6591. __Pyx_XDECREF(__pyx_t_7);
  6592. __Pyx_XDECREF(__pyx_t_8);
  6593. __Pyx_XDECREF(__pyx_t_16);
  6594. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.read_as", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6595. __pyx_r = NULL;
  6596. __pyx_L0:;
  6597. __Pyx_XDECREF(__pyx_v_codecs);
  6598. __Pyx_XDECREF(__pyx_v_f);
  6599. __Pyx_XDECREF(__pyx_v_data);
  6600. __Pyx_XDECREF(__pyx_v_e);
  6601. __Pyx_XGIVEREF(__pyx_r);
  6602. __Pyx_RefNannyFinishContext();
  6603. return __pyx_r;
  6604. }
  6605. /* "lib/Naked/toolshed/c/file.pyx":271
  6606. * # Tests: test_IO.py :: test_file_readlines, test_file_readlines_missing_file
  6607. * #------------------------------------------------------------------------------
  6608. * def readlines(self): # <<<<<<<<<<<<<<
  6609. * try:
  6610. * return self.readlines_utf8() # read as utf8 encoded file
  6611. */
  6612. /* Python wrapper */
  6613. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_9readlines(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
  6614. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileReader_9readlines = {__Pyx_NAMESTR("readlines"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_9readlines, METH_O, __Pyx_DOCSTR(0)};
  6615. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_9readlines(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  6616. PyObject *__pyx_r = 0;
  6617. __Pyx_RefNannyDeclarations
  6618. __Pyx_RefNannySetupContext("readlines (wrapper)", 0);
  6619. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_8readlines(__pyx_self, ((PyObject *)__pyx_v_self));
  6620. /* function exit code */
  6621. __Pyx_RefNannyFinishContext();
  6622. return __pyx_r;
  6623. }
  6624. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_8readlines(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  6625. PyObject *__pyx_v_e = NULL;
  6626. PyObject *__pyx_r = NULL;
  6627. __Pyx_RefNannyDeclarations
  6628. PyObject *__pyx_t_1 = NULL;
  6629. PyObject *__pyx_t_2 = NULL;
  6630. PyObject *__pyx_t_3 = NULL;
  6631. PyObject *__pyx_t_4 = NULL;
  6632. PyObject *__pyx_t_5 = NULL;
  6633. int __pyx_t_6;
  6634. PyObject *__pyx_t_7 = NULL;
  6635. PyObject *__pyx_t_8 = NULL;
  6636. int __pyx_t_9;
  6637. PyObject *__pyx_t_10 = NULL;
  6638. int __pyx_lineno = 0;
  6639. const char *__pyx_filename = NULL;
  6640. int __pyx_clineno = 0;
  6641. __Pyx_RefNannySetupContext("readlines", 0);
  6642. /* "lib/Naked/toolshed/c/file.pyx":272
  6643. * #------------------------------------------------------------------------------
  6644. * def readlines(self):
  6645. * try: # <<<<<<<<<<<<<<
  6646. * return self.readlines_utf8() # read as utf8 encoded file
  6647. * except Exception as e:
  6648. */
  6649. {
  6650. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  6651. __Pyx_XGOTREF(__pyx_t_1);
  6652. __Pyx_XGOTREF(__pyx_t_2);
  6653. __Pyx_XGOTREF(__pyx_t_3);
  6654. /*try:*/ {
  6655. /* "lib/Naked/toolshed/c/file.pyx":273
  6656. * def readlines(self):
  6657. * try:
  6658. * return self.readlines_utf8() # read as utf8 encoded file # <<<<<<<<<<<<<<
  6659. * except Exception as e:
  6660. * if DEBUG_FLAG:
  6661. */
  6662. __Pyx_XDECREF(__pyx_r);
  6663. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_readlines_utf8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6664. __Pyx_GOTREF(__pyx_t_4);
  6665. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6666. __Pyx_GOTREF(__pyx_t_5);
  6667. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6668. __pyx_r = __pyx_t_5;
  6669. __pyx_t_5 = 0;
  6670. goto __pyx_L7_try_return;
  6671. }
  6672. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  6673. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  6674. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  6675. goto __pyx_L10_try_end;
  6676. __pyx_L3_error:;
  6677. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  6678. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  6679. /* "lib/Naked/toolshed/c/file.pyx":274
  6680. * try:
  6681. * return self.readlines_utf8() # read as utf8 encoded file
  6682. * except Exception as e: # <<<<<<<<<<<<<<
  6683. * if DEBUG_FLAG:
  6684. * sys.stderr.write("Naked Framework Error: Unable to read text from the requested file with the readlines() method (Naked.toolshed.file.py).")
  6685. */
  6686. __pyx_t_6 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  6687. if (__pyx_t_6) {
  6688. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.readlines", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6689. if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6690. __Pyx_GOTREF(__pyx_t_5);
  6691. __Pyx_GOTREF(__pyx_t_4);
  6692. __Pyx_GOTREF(__pyx_t_7);
  6693. __Pyx_INCREF(__pyx_t_4);
  6694. __pyx_v_e = __pyx_t_4;
  6695. /* "lib/Naked/toolshed/c/file.pyx":275
  6696. * return self.readlines_utf8() # read as utf8 encoded file
  6697. * except Exception as e:
  6698. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  6699. * sys.stderr.write("Naked Framework Error: Unable to read text from the requested file with the readlines() method (Naked.toolshed.file.py).")
  6700. * raise e
  6701. */
  6702. __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6703. __Pyx_GOTREF(__pyx_t_8);
  6704. __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6705. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6706. if (__pyx_t_9) {
  6707. /* "lib/Naked/toolshed/c/file.pyx":276
  6708. * except Exception as e:
  6709. * if DEBUG_FLAG:
  6710. * sys.stderr.write("Naked Framework Error: Unable to read text from the requested file with the readlines() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  6711. * raise e
  6712. *
  6713. */
  6714. __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6715. __Pyx_GOTREF(__pyx_t_8);
  6716. __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_stderr); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6717. __Pyx_GOTREF(__pyx_t_10);
  6718. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6719. __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_write); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6720. __Pyx_GOTREF(__pyx_t_8);
  6721. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  6722. __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6723. __Pyx_GOTREF(__pyx_t_10);
  6724. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6725. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  6726. goto __pyx_L13;
  6727. }
  6728. __pyx_L13:;
  6729. /* "lib/Naked/toolshed/c/file.pyx":277
  6730. * if DEBUG_FLAG:
  6731. * sys.stderr.write("Naked Framework Error: Unable to read text from the requested file with the readlines() method (Naked.toolshed.file.py).")
  6732. * raise e # <<<<<<<<<<<<<<
  6733. *
  6734. * #------------------------------------------------------------------------------
  6735. */
  6736. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  6737. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  6738. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6739. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6740. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6741. goto __pyx_L4_exception_handled;
  6742. }
  6743. goto __pyx_L5_except_error;
  6744. __pyx_L5_except_error:;
  6745. __Pyx_XGIVEREF(__pyx_t_1);
  6746. __Pyx_XGIVEREF(__pyx_t_2);
  6747. __Pyx_XGIVEREF(__pyx_t_3);
  6748. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  6749. goto __pyx_L1_error;
  6750. __pyx_L7_try_return:;
  6751. __Pyx_XGIVEREF(__pyx_t_1);
  6752. __Pyx_XGIVEREF(__pyx_t_2);
  6753. __Pyx_XGIVEREF(__pyx_t_3);
  6754. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  6755. goto __pyx_L0;
  6756. __pyx_L4_exception_handled:;
  6757. __Pyx_XGIVEREF(__pyx_t_1);
  6758. __Pyx_XGIVEREF(__pyx_t_2);
  6759. __Pyx_XGIVEREF(__pyx_t_3);
  6760. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  6761. __pyx_L10_try_end:;
  6762. }
  6763. /* "lib/Naked/toolshed/c/file.pyx":271
  6764. * # Tests: test_IO.py :: test_file_readlines, test_file_readlines_missing_file
  6765. * #------------------------------------------------------------------------------
  6766. * def readlines(self): # <<<<<<<<<<<<<<
  6767. * try:
  6768. * return self.readlines_utf8() # read as utf8 encoded file
  6769. */
  6770. /* function exit code */
  6771. __pyx_L1_error:;
  6772. __Pyx_XDECREF(__pyx_t_4);
  6773. __Pyx_XDECREF(__pyx_t_5);
  6774. __Pyx_XDECREF(__pyx_t_7);
  6775. __Pyx_XDECREF(__pyx_t_8);
  6776. __Pyx_XDECREF(__pyx_t_10);
  6777. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.readlines", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6778. __pyx_r = NULL;
  6779. __pyx_L0:;
  6780. __Pyx_XDECREF(__pyx_v_e);
  6781. __Pyx_XGIVEREF(__pyx_r);
  6782. __Pyx_RefNannyFinishContext();
  6783. return __pyx_r;
  6784. }
  6785. /* "lib/Naked/toolshed/c/file.pyx":285
  6786. * # Tests: test_IO.py ::
  6787. * #------------------------------------------------------------------------------
  6788. * def readlines_as(self, dev_spec_encoding): # <<<<<<<<<<<<<<
  6789. * try:
  6790. * if dev_spec_encoding == "":
  6791. */
  6792. /* Python wrapper */
  6793. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_11readlines_as(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  6794. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileReader_11readlines_as = {__Pyx_NAMESTR("readlines_as"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_11readlines_as, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  6795. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_11readlines_as(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  6796. PyObject *__pyx_v_self = 0;
  6797. PyObject *__pyx_v_dev_spec_encoding = 0;
  6798. int __pyx_lineno = 0;
  6799. const char *__pyx_filename = NULL;
  6800. int __pyx_clineno = 0;
  6801. PyObject *__pyx_r = 0;
  6802. __Pyx_RefNannyDeclarations
  6803. __Pyx_RefNannySetupContext("readlines_as (wrapper)", 0);
  6804. {
  6805. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_dev_spec_encoding,0};
  6806. PyObject* values[2] = {0,0};
  6807. if (unlikely(__pyx_kwds)) {
  6808. Py_ssize_t kw_args;
  6809. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  6810. switch (pos_args) {
  6811. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6812. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6813. case 0: break;
  6814. default: goto __pyx_L5_argtuple_error;
  6815. }
  6816. kw_args = PyDict_Size(__pyx_kwds);
  6817. switch (pos_args) {
  6818. case 0:
  6819. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
  6820. else goto __pyx_L5_argtuple_error;
  6821. case 1:
  6822. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dev_spec_encoding)) != 0)) kw_args--;
  6823. else {
  6824. __Pyx_RaiseArgtupleInvalid("readlines_as", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6825. }
  6826. }
  6827. if (unlikely(kw_args > 0)) {
  6828. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "readlines_as") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6829. }
  6830. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  6831. goto __pyx_L5_argtuple_error;
  6832. } else {
  6833. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6834. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6835. }
  6836. __pyx_v_self = values[0];
  6837. __pyx_v_dev_spec_encoding = values[1];
  6838. }
  6839. goto __pyx_L4_argument_unpacking_done;
  6840. __pyx_L5_argtuple_error:;
  6841. __Pyx_RaiseArgtupleInvalid("readlines_as", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6842. __pyx_L3_error:;
  6843. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.readlines_as", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6844. __Pyx_RefNannyFinishContext();
  6845. return NULL;
  6846. __pyx_L4_argument_unpacking_done:;
  6847. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_10readlines_as(__pyx_self, __pyx_v_self, __pyx_v_dev_spec_encoding);
  6848. /* function exit code */
  6849. __Pyx_RefNannyFinishContext();
  6850. return __pyx_r;
  6851. }
  6852. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_10readlines_as(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_dev_spec_encoding) {
  6853. PyObject *__pyx_v_codecs = NULL;
  6854. PyObject *__pyx_v_reader = NULL;
  6855. PyObject *__pyx_v_data_list = NULL;
  6856. PyObject *__pyx_v_line = NULL;
  6857. PyObject *__pyx_v_e = NULL;
  6858. PyObject *__pyx_r = NULL;
  6859. __Pyx_RefNannyDeclarations
  6860. PyObject *__pyx_t_1 = NULL;
  6861. PyObject *__pyx_t_2 = NULL;
  6862. PyObject *__pyx_t_3 = NULL;
  6863. int __pyx_t_4;
  6864. PyObject *__pyx_t_5 = NULL;
  6865. PyObject *__pyx_t_6 = NULL;
  6866. PyObject *__pyx_t_7 = NULL;
  6867. PyObject *__pyx_t_8 = NULL;
  6868. PyObject *__pyx_t_9 = NULL;
  6869. PyObject *__pyx_t_10 = NULL;
  6870. PyObject *__pyx_t_11 = NULL;
  6871. PyObject *__pyx_t_12 = NULL;
  6872. Py_ssize_t __pyx_t_13;
  6873. PyObject *(*__pyx_t_14)(PyObject *);
  6874. int __pyx_t_15;
  6875. PyObject *__pyx_t_16 = NULL;
  6876. int __pyx_t_17;
  6877. int __pyx_t_18;
  6878. PyObject *__pyx_t_19 = NULL;
  6879. int __pyx_lineno = 0;
  6880. const char *__pyx_filename = NULL;
  6881. int __pyx_clineno = 0;
  6882. __Pyx_RefNannySetupContext("readlines_as", 0);
  6883. /* "lib/Naked/toolshed/c/file.pyx":286
  6884. * #------------------------------------------------------------------------------
  6885. * def readlines_as(self, dev_spec_encoding):
  6886. * try: # <<<<<<<<<<<<<<
  6887. * if dev_spec_encoding == "":
  6888. * raise RuntimeError("The text file encoding was not specified as an argument to the readlines_as method (Naked.toolshed.file.py:readlines_as).")
  6889. */
  6890. {
  6891. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  6892. __Pyx_XGOTREF(__pyx_t_1);
  6893. __Pyx_XGOTREF(__pyx_t_2);
  6894. __Pyx_XGOTREF(__pyx_t_3);
  6895. /*try:*/ {
  6896. /* "lib/Naked/toolshed/c/file.pyx":287
  6897. * def readlines_as(self, dev_spec_encoding):
  6898. * try:
  6899. * if dev_spec_encoding == "": # <<<<<<<<<<<<<<
  6900. * raise RuntimeError("The text file encoding was not specified as an argument to the readlines_as method (Naked.toolshed.file.py:readlines_as).")
  6901. * import codecs
  6902. */
  6903. __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_dev_spec_encoding, __pyx_kp_s__13, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6904. if (__pyx_t_4) {
  6905. /* "lib/Naked/toolshed/c/file.pyx":288
  6906. * try:
  6907. * if dev_spec_encoding == "":
  6908. * raise RuntimeError("The text file encoding was not specified as an argument to the readlines_as method (Naked.toolshed.file.py:readlines_as).") # <<<<<<<<<<<<<<
  6909. * import codecs
  6910. * with codecs.open(self.filepath, encoding=dev_spec_encoding, mode='r') as reader:
  6911. */
  6912. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6913. __Pyx_GOTREF(__pyx_t_5);
  6914. __Pyx_Raise(__pyx_t_5, 0, 0, 0);
  6915. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6916. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6917. }
  6918. /* "lib/Naked/toolshed/c/file.pyx":289
  6919. * if dev_spec_encoding == "":
  6920. * raise RuntimeError("The text file encoding was not specified as an argument to the readlines_as method (Naked.toolshed.file.py:readlines_as).")
  6921. * import codecs # <<<<<<<<<<<<<<
  6922. * with codecs.open(self.filepath, encoding=dev_spec_encoding, mode='r') as reader:
  6923. * data_list = []
  6924. */
  6925. __pyx_t_5 = __Pyx_Import(__pyx_n_s_codecs, 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6926. __Pyx_GOTREF(__pyx_t_5);
  6927. __pyx_v_codecs = __pyx_t_5;
  6928. __pyx_t_5 = 0;
  6929. /* "lib/Naked/toolshed/c/file.pyx":290
  6930. * raise RuntimeError("The text file encoding was not specified as an argument to the readlines_as method (Naked.toolshed.file.py:readlines_as).")
  6931. * import codecs
  6932. * with codecs.open(self.filepath, encoding=dev_spec_encoding, mode='r') as reader: # <<<<<<<<<<<<<<
  6933. * data_list = []
  6934. * for line in reader:
  6935. */
  6936. /*with:*/ {
  6937. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_codecs, __pyx_n_s_open); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6938. __Pyx_GOTREF(__pyx_t_5);
  6939. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6940. __Pyx_GOTREF(__pyx_t_6);
  6941. __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6942. __Pyx_GOTREF(__pyx_t_7);
  6943. PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
  6944. __Pyx_GIVEREF(__pyx_t_6);
  6945. __pyx_t_6 = 0;
  6946. __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6947. __Pyx_GOTREF(__pyx_t_6);
  6948. if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_encoding, __pyx_v_dev_spec_encoding) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6949. if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_mode, __pyx_n_s_r) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6950. __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6951. __Pyx_GOTREF(__pyx_t_8);
  6952. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6953. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6954. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6955. __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_8, __pyx_n_s_exit); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  6956. __Pyx_GOTREF(__pyx_t_9);
  6957. __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_8, __pyx_n_s_enter); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
  6958. __Pyx_GOTREF(__pyx_t_6);
  6959. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
  6960. __Pyx_GOTREF(__pyx_t_7);
  6961. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6962. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6963. /*try:*/ {
  6964. {
  6965. __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
  6966. __Pyx_XGOTREF(__pyx_t_10);
  6967. __Pyx_XGOTREF(__pyx_t_11);
  6968. __Pyx_XGOTREF(__pyx_t_12);
  6969. /*try:*/ {
  6970. __Pyx_INCREF(__pyx_t_7);
  6971. __pyx_v_reader = __pyx_t_7;
  6972. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6973. /* "lib/Naked/toolshed/c/file.pyx":291
  6974. * import codecs
  6975. * with codecs.open(self.filepath, encoding=dev_spec_encoding, mode='r') as reader:
  6976. * data_list = [] # <<<<<<<<<<<<<<
  6977. * for line in reader:
  6978. * data_list.append(line)
  6979. */
  6980. __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  6981. __Pyx_GOTREF(__pyx_t_7);
  6982. __pyx_v_data_list = ((PyObject*)__pyx_t_7);
  6983. __pyx_t_7 = 0;
  6984. /* "lib/Naked/toolshed/c/file.pyx":292
  6985. * with codecs.open(self.filepath, encoding=dev_spec_encoding, mode='r') as reader:
  6986. * data_list = []
  6987. * for line in reader: # <<<<<<<<<<<<<<
  6988. * data_list.append(line)
  6989. * return data_list
  6990. */
  6991. if (PyList_CheckExact(__pyx_v_reader) || PyTuple_CheckExact(__pyx_v_reader)) {
  6992. __pyx_t_7 = __pyx_v_reader; __Pyx_INCREF(__pyx_t_7); __pyx_t_13 = 0;
  6993. __pyx_t_14 = NULL;
  6994. } else {
  6995. __pyx_t_13 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_reader); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  6996. __Pyx_GOTREF(__pyx_t_7);
  6997. __pyx_t_14 = Py_TYPE(__pyx_t_7)->tp_iternext;
  6998. }
  6999. for (;;) {
  7000. if (!__pyx_t_14 && PyList_CheckExact(__pyx_t_7)) {
  7001. if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_7)) break;
  7002. #if CYTHON_COMPILING_IN_CPYTHON
  7003. __pyx_t_8 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_13); __Pyx_INCREF(__pyx_t_8); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  7004. #else
  7005. __pyx_t_8 = PySequence_ITEM(__pyx_t_7, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  7006. #endif
  7007. } else if (!__pyx_t_14 && PyTuple_CheckExact(__pyx_t_7)) {
  7008. if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
  7009. #if CYTHON_COMPILING_IN_CPYTHON
  7010. __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_13); __Pyx_INCREF(__pyx_t_8); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  7011. #else
  7012. __pyx_t_8 = PySequence_ITEM(__pyx_t_7, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  7013. #endif
  7014. } else {
  7015. __pyx_t_8 = __pyx_t_14(__pyx_t_7);
  7016. if (unlikely(!__pyx_t_8)) {
  7017. PyObject* exc_type = PyErr_Occurred();
  7018. if (exc_type) {
  7019. if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  7020. else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  7021. }
  7022. break;
  7023. }
  7024. __Pyx_GOTREF(__pyx_t_8);
  7025. }
  7026. __Pyx_XDECREF_SET(__pyx_v_line, __pyx_t_8);
  7027. __pyx_t_8 = 0;
  7028. /* "lib/Naked/toolshed/c/file.pyx":293
  7029. * data_list = []
  7030. * for line in reader:
  7031. * data_list.append(line) # <<<<<<<<<<<<<<
  7032. * return data_list
  7033. * except Exception as e:
  7034. */
  7035. __pyx_t_15 = __Pyx_PyList_Append(__pyx_v_data_list, __pyx_v_line); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
  7036. }
  7037. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7038. /* "lib/Naked/toolshed/c/file.pyx":294
  7039. * for line in reader:
  7040. * data_list.append(line)
  7041. * return data_list # <<<<<<<<<<<<<<
  7042. * except Exception as e:
  7043. * if DEBUG_FLAG:
  7044. */
  7045. __Pyx_XDECREF(__pyx_r);
  7046. __Pyx_INCREF(__pyx_v_data_list);
  7047. __pyx_r = __pyx_v_data_list;
  7048. goto __pyx_L22_try_return;
  7049. }
  7050. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  7051. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  7052. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  7053. goto __pyx_L25_try_end;
  7054. __pyx_L18_error:;
  7055. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  7056. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  7057. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  7058. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7059. /* "lib/Naked/toolshed/c/file.pyx":290
  7060. * raise RuntimeError("The text file encoding was not specified as an argument to the readlines_as method (Naked.toolshed.file.py:readlines_as).")
  7061. * import codecs
  7062. * with codecs.open(self.filepath, encoding=dev_spec_encoding, mode='r') as reader: # <<<<<<<<<<<<<<
  7063. * data_list = []
  7064. * for line in reader:
  7065. */
  7066. /*except:*/ {
  7067. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.readlines_as", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7068. if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  7069. __Pyx_GOTREF(__pyx_t_7);
  7070. __Pyx_GOTREF(__pyx_t_8);
  7071. __Pyx_GOTREF(__pyx_t_6);
  7072. __pyx_t_5 = PyTuple_Pack(3, __pyx_t_7, __pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  7073. __Pyx_GOTREF(__pyx_t_5);
  7074. __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_5, NULL);
  7075. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  7076. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7077. if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  7078. __Pyx_GOTREF(__pyx_t_16);
  7079. __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_16);
  7080. __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  7081. if (__pyx_t_4 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  7082. __pyx_t_17 = ((!(__pyx_t_4 != 0)) != 0);
  7083. if (__pyx_t_17) {
  7084. __Pyx_GIVEREF(__pyx_t_7);
  7085. __Pyx_GIVEREF(__pyx_t_8);
  7086. __Pyx_XGIVEREF(__pyx_t_6);
  7087. __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_6);
  7088. __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_6 = 0;
  7089. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
  7090. }
  7091. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7092. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7093. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7094. goto __pyx_L19_exception_handled;
  7095. }
  7096. __pyx_L20_except_error:;
  7097. __Pyx_XGIVEREF(__pyx_t_10);
  7098. __Pyx_XGIVEREF(__pyx_t_11);
  7099. __Pyx_XGIVEREF(__pyx_t_12);
  7100. __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
  7101. goto __pyx_L3_error;
  7102. __pyx_L22_try_return:;
  7103. __Pyx_XGIVEREF(__pyx_t_10);
  7104. __Pyx_XGIVEREF(__pyx_t_11);
  7105. __Pyx_XGIVEREF(__pyx_t_12);
  7106. __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
  7107. goto __pyx_L15_return;
  7108. __pyx_L19_exception_handled:;
  7109. __Pyx_XGIVEREF(__pyx_t_10);
  7110. __Pyx_XGIVEREF(__pyx_t_11);
  7111. __Pyx_XGIVEREF(__pyx_t_12);
  7112. __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
  7113. __pyx_L25_try_end:;
  7114. }
  7115. }
  7116. /*finally:*/ {
  7117. /*normal exit:*/{
  7118. if (__pyx_t_9) {
  7119. __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__34, NULL);
  7120. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  7121. if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7122. __Pyx_GOTREF(__pyx_t_12);
  7123. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  7124. }
  7125. goto __pyx_L17;
  7126. }
  7127. __pyx_L15_return: {
  7128. __pyx_t_12 = __pyx_r;
  7129. __pyx_r = 0;
  7130. if (__pyx_t_9) {
  7131. __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__35, NULL);
  7132. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  7133. if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7134. __Pyx_GOTREF(__pyx_t_11);
  7135. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  7136. }
  7137. __pyx_r = __pyx_t_12;
  7138. __pyx_t_12 = 0;
  7139. goto __pyx_L7_try_return;
  7140. }
  7141. __pyx_L17:;
  7142. }
  7143. goto __pyx_L32;
  7144. __pyx_L12_error:;
  7145. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  7146. goto __pyx_L3_error;
  7147. __pyx_L32:;
  7148. }
  7149. }
  7150. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  7151. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  7152. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  7153. goto __pyx_L10_try_end;
  7154. __pyx_L3_error:;
  7155. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  7156. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7157. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  7158. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  7159. /* "lib/Naked/toolshed/c/file.pyx":295
  7160. * data_list.append(line)
  7161. * return data_list
  7162. * except Exception as e: # <<<<<<<<<<<<<<
  7163. * if DEBUG_FLAG:
  7164. * sys.stderr.write("Naked Framework Error: unable to read lines in the specified encoding with the readlines_as method (Naked.toolshed.file.py).")
  7165. */
  7166. __pyx_t_18 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  7167. if (__pyx_t_18) {
  7168. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.readlines_as", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7169. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_8, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  7170. __Pyx_GOTREF(__pyx_t_6);
  7171. __Pyx_GOTREF(__pyx_t_8);
  7172. __Pyx_GOTREF(__pyx_t_7);
  7173. __Pyx_INCREF(__pyx_t_8);
  7174. __pyx_v_e = __pyx_t_8;
  7175. /* "lib/Naked/toolshed/c/file.pyx":296
  7176. * return data_list
  7177. * except Exception as e:
  7178. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  7179. * sys.stderr.write("Naked Framework Error: unable to read lines in the specified encoding with the readlines_as method (Naked.toolshed.file.py).")
  7180. * raise e
  7181. */
  7182. __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  7183. __Pyx_GOTREF(__pyx_t_5);
  7184. __pyx_t_17 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_17 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  7185. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7186. if (__pyx_t_17) {
  7187. /* "lib/Naked/toolshed/c/file.pyx":297
  7188. * except Exception as e:
  7189. * if DEBUG_FLAG:
  7190. * sys.stderr.write("Naked Framework Error: unable to read lines in the specified encoding with the readlines_as method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  7191. * raise e
  7192. *
  7193. */
  7194. __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  7195. __Pyx_GOTREF(__pyx_t_5);
  7196. __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_stderr); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  7197. __Pyx_GOTREF(__pyx_t_19);
  7198. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7199. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_n_s_write); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  7200. __Pyx_GOTREF(__pyx_t_5);
  7201. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  7202. __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  7203. __Pyx_GOTREF(__pyx_t_19);
  7204. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7205. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  7206. goto __pyx_L35;
  7207. }
  7208. __pyx_L35:;
  7209. /* "lib/Naked/toolshed/c/file.pyx":298
  7210. * if DEBUG_FLAG:
  7211. * sys.stderr.write("Naked Framework Error: unable to read lines in the specified encoding with the readlines_as method (Naked.toolshed.file.py).")
  7212. * raise e # <<<<<<<<<<<<<<
  7213. *
  7214. * #------------------------------------------------------------------------------
  7215. */
  7216. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  7217. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  7218. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7219. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7220. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7221. goto __pyx_L4_exception_handled;
  7222. }
  7223. goto __pyx_L5_except_error;
  7224. __pyx_L5_except_error:;
  7225. __Pyx_XGIVEREF(__pyx_t_1);
  7226. __Pyx_XGIVEREF(__pyx_t_2);
  7227. __Pyx_XGIVEREF(__pyx_t_3);
  7228. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  7229. goto __pyx_L1_error;
  7230. __pyx_L7_try_return:;
  7231. __Pyx_XGIVEREF(__pyx_t_1);
  7232. __Pyx_XGIVEREF(__pyx_t_2);
  7233. __Pyx_XGIVEREF(__pyx_t_3);
  7234. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  7235. goto __pyx_L0;
  7236. __pyx_L4_exception_handled:;
  7237. __Pyx_XGIVEREF(__pyx_t_1);
  7238. __Pyx_XGIVEREF(__pyx_t_2);
  7239. __Pyx_XGIVEREF(__pyx_t_3);
  7240. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  7241. __pyx_L10_try_end:;
  7242. }
  7243. /* "lib/Naked/toolshed/c/file.pyx":285
  7244. * # Tests: test_IO.py ::
  7245. * #------------------------------------------------------------------------------
  7246. * def readlines_as(self, dev_spec_encoding): # <<<<<<<<<<<<<<
  7247. * try:
  7248. * if dev_spec_encoding == "":
  7249. */
  7250. /* function exit code */
  7251. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  7252. goto __pyx_L0;
  7253. __pyx_L1_error:;
  7254. __Pyx_XDECREF(__pyx_t_5);
  7255. __Pyx_XDECREF(__pyx_t_6);
  7256. __Pyx_XDECREF(__pyx_t_7);
  7257. __Pyx_XDECREF(__pyx_t_8);
  7258. __Pyx_XDECREF(__pyx_t_19);
  7259. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.readlines_as", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7260. __pyx_r = NULL;
  7261. __pyx_L0:;
  7262. __Pyx_XDECREF(__pyx_v_codecs);
  7263. __Pyx_XDECREF(__pyx_v_reader);
  7264. __Pyx_XDECREF(__pyx_v_data_list);
  7265. __Pyx_XDECREF(__pyx_v_line);
  7266. __Pyx_XDECREF(__pyx_v_e);
  7267. __Pyx_XGIVEREF(__pyx_r);
  7268. __Pyx_RefNannyFinishContext();
  7269. return __pyx_r;
  7270. }
  7271. /* "lib/Naked/toolshed/c/file.pyx":306
  7272. * # Tests: test_IO.py :: test_file_readlines_unicode, test_file_readlines_utf8_missing_file
  7273. * #------------------------------------------------------------------------------
  7274. * def readlines_utf8(self): # <<<<<<<<<<<<<<
  7275. * try:
  7276. * import codecs
  7277. */
  7278. /* Python wrapper */
  7279. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_13readlines_utf8(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
  7280. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileReader_13readlines_utf8 = {__Pyx_NAMESTR("readlines_utf8"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_13readlines_utf8, METH_O, __Pyx_DOCSTR(0)};
  7281. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_13readlines_utf8(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  7282. PyObject *__pyx_r = 0;
  7283. __Pyx_RefNannyDeclarations
  7284. __Pyx_RefNannySetupContext("readlines_utf8 (wrapper)", 0);
  7285. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_12readlines_utf8(__pyx_self, ((PyObject *)__pyx_v_self));
  7286. /* function exit code */
  7287. __Pyx_RefNannyFinishContext();
  7288. return __pyx_r;
  7289. }
  7290. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_12readlines_utf8(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  7291. PyObject *__pyx_v_codecs = NULL;
  7292. PyObject *__pyx_v_uni_reader = NULL;
  7293. PyObject *__pyx_v_modified_text_list = NULL;
  7294. PyObject *__pyx_v_line = NULL;
  7295. PyObject *__pyx_v_unicodedata = NULL;
  7296. PyObject *__pyx_v_norm_line = NULL;
  7297. PyObject *__pyx_v_e = NULL;
  7298. PyObject *__pyx_r = NULL;
  7299. __Pyx_RefNannyDeclarations
  7300. PyObject *__pyx_t_1 = NULL;
  7301. PyObject *__pyx_t_2 = NULL;
  7302. PyObject *__pyx_t_3 = NULL;
  7303. PyObject *__pyx_t_4 = NULL;
  7304. PyObject *__pyx_t_5 = NULL;
  7305. PyObject *__pyx_t_6 = NULL;
  7306. PyObject *__pyx_t_7 = NULL;
  7307. PyObject *__pyx_t_8 = NULL;
  7308. PyObject *__pyx_t_9 = NULL;
  7309. PyObject *__pyx_t_10 = NULL;
  7310. PyObject *__pyx_t_11 = NULL;
  7311. Py_ssize_t __pyx_t_12;
  7312. PyObject *(*__pyx_t_13)(PyObject *);
  7313. int __pyx_t_14;
  7314. PyObject *__pyx_t_15 = NULL;
  7315. int __pyx_t_16;
  7316. int __pyx_t_17;
  7317. int __pyx_t_18;
  7318. PyObject *__pyx_t_19 = NULL;
  7319. int __pyx_lineno = 0;
  7320. const char *__pyx_filename = NULL;
  7321. int __pyx_clineno = 0;
  7322. __Pyx_RefNannySetupContext("readlines_utf8", 0);
  7323. /* "lib/Naked/toolshed/c/file.pyx":307
  7324. * #------------------------------------------------------------------------------
  7325. * def readlines_utf8(self):
  7326. * try: # <<<<<<<<<<<<<<
  7327. * import codecs
  7328. * with codecs.open(self.filepath, encoding='utf-8', mode='r') as uni_reader:
  7329. */
  7330. {
  7331. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  7332. __Pyx_XGOTREF(__pyx_t_1);
  7333. __Pyx_XGOTREF(__pyx_t_2);
  7334. __Pyx_XGOTREF(__pyx_t_3);
  7335. /*try:*/ {
  7336. /* "lib/Naked/toolshed/c/file.pyx":308
  7337. * def readlines_utf8(self):
  7338. * try:
  7339. * import codecs # <<<<<<<<<<<<<<
  7340. * with codecs.open(self.filepath, encoding='utf-8', mode='r') as uni_reader:
  7341. * modified_text_list = []
  7342. */
  7343. __pyx_t_4 = __Pyx_Import(__pyx_n_s_codecs, 0, -1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7344. __Pyx_GOTREF(__pyx_t_4);
  7345. __pyx_v_codecs = __pyx_t_4;
  7346. __pyx_t_4 = 0;
  7347. /* "lib/Naked/toolshed/c/file.pyx":309
  7348. * try:
  7349. * import codecs
  7350. * with codecs.open(self.filepath, encoding='utf-8', mode='r') as uni_reader: # <<<<<<<<<<<<<<
  7351. * modified_text_list = []
  7352. * for line in uni_reader:
  7353. */
  7354. /*with:*/ {
  7355. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_codecs, __pyx_n_s_open); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7356. __Pyx_GOTREF(__pyx_t_4);
  7357. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7358. __Pyx_GOTREF(__pyx_t_5);
  7359. __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7360. __Pyx_GOTREF(__pyx_t_6);
  7361. PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
  7362. __Pyx_GIVEREF(__pyx_t_5);
  7363. __pyx_t_5 = 0;
  7364. __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7365. __Pyx_GOTREF(__pyx_t_5);
  7366. if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_encoding, __pyx_kp_s_utf_8_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7367. if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_mode, __pyx_n_s_r) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7368. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7369. __Pyx_GOTREF(__pyx_t_7);
  7370. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7371. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7372. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7373. __pyx_t_8 = __Pyx_PyObject_LookupSpecial(__pyx_t_7, __pyx_n_s_exit); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7374. __Pyx_GOTREF(__pyx_t_8);
  7375. __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_7, __pyx_n_s_enter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
  7376. __Pyx_GOTREF(__pyx_t_5);
  7377. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
  7378. __Pyx_GOTREF(__pyx_t_6);
  7379. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7380. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7381. /*try:*/ {
  7382. {
  7383. __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
  7384. __Pyx_XGOTREF(__pyx_t_9);
  7385. __Pyx_XGOTREF(__pyx_t_10);
  7386. __Pyx_XGOTREF(__pyx_t_11);
  7387. /*try:*/ {
  7388. __Pyx_INCREF(__pyx_t_6);
  7389. __pyx_v_uni_reader = __pyx_t_6;
  7390. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7391. /* "lib/Naked/toolshed/c/file.pyx":310
  7392. * import codecs
  7393. * with codecs.open(self.filepath, encoding='utf-8', mode='r') as uni_reader:
  7394. * modified_text_list = [] # <<<<<<<<<<<<<<
  7395. * for line in uni_reader:
  7396. * import unicodedata
  7397. */
  7398. __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7399. __Pyx_GOTREF(__pyx_t_6);
  7400. __pyx_v_modified_text_list = ((PyObject*)__pyx_t_6);
  7401. __pyx_t_6 = 0;
  7402. /* "lib/Naked/toolshed/c/file.pyx":311
  7403. * with codecs.open(self.filepath, encoding='utf-8', mode='r') as uni_reader:
  7404. * modified_text_list = []
  7405. * for line in uni_reader: # <<<<<<<<<<<<<<
  7406. * import unicodedata
  7407. * norm_line = unicodedata.normalize('NFKD', line) # NKFD normalization of the unicode data before use
  7408. */
  7409. if (PyList_CheckExact(__pyx_v_uni_reader) || PyTuple_CheckExact(__pyx_v_uni_reader)) {
  7410. __pyx_t_6 = __pyx_v_uni_reader; __Pyx_INCREF(__pyx_t_6); __pyx_t_12 = 0;
  7411. __pyx_t_13 = NULL;
  7412. } else {
  7413. __pyx_t_12 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_uni_reader); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7414. __Pyx_GOTREF(__pyx_t_6);
  7415. __pyx_t_13 = Py_TYPE(__pyx_t_6)->tp_iternext;
  7416. }
  7417. for (;;) {
  7418. if (!__pyx_t_13 && PyList_CheckExact(__pyx_t_6)) {
  7419. if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_6)) break;
  7420. #if CYTHON_COMPILING_IN_CPYTHON
  7421. __pyx_t_7 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_12); __Pyx_INCREF(__pyx_t_7); __pyx_t_12++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7422. #else
  7423. __pyx_t_7 = PySequence_ITEM(__pyx_t_6, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7424. #endif
  7425. } else if (!__pyx_t_13 && PyTuple_CheckExact(__pyx_t_6)) {
  7426. if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
  7427. #if CYTHON_COMPILING_IN_CPYTHON
  7428. __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_12); __Pyx_INCREF(__pyx_t_7); __pyx_t_12++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7429. #else
  7430. __pyx_t_7 = PySequence_ITEM(__pyx_t_6, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7431. #endif
  7432. } else {
  7433. __pyx_t_7 = __pyx_t_13(__pyx_t_6);
  7434. if (unlikely(!__pyx_t_7)) {
  7435. PyObject* exc_type = PyErr_Occurred();
  7436. if (exc_type) {
  7437. if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  7438. else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7439. }
  7440. break;
  7441. }
  7442. __Pyx_GOTREF(__pyx_t_7);
  7443. }
  7444. __Pyx_XDECREF_SET(__pyx_v_line, __pyx_t_7);
  7445. __pyx_t_7 = 0;
  7446. /* "lib/Naked/toolshed/c/file.pyx":312
  7447. * modified_text_list = []
  7448. * for line in uni_reader:
  7449. * import unicodedata # <<<<<<<<<<<<<<
  7450. * norm_line = unicodedata.normalize('NFKD', line) # NKFD normalization of the unicode data before use
  7451. * modified_text_list.append(norm_line)
  7452. */
  7453. __pyx_t_7 = __Pyx_Import(__pyx_n_s_unicodedata, 0, -1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7454. __Pyx_GOTREF(__pyx_t_7);
  7455. __Pyx_XDECREF_SET(__pyx_v_unicodedata, __pyx_t_7);
  7456. __pyx_t_7 = 0;
  7457. /* "lib/Naked/toolshed/c/file.pyx":313
  7458. * for line in uni_reader:
  7459. * import unicodedata
  7460. * norm_line = unicodedata.normalize('NFKD', line) # NKFD normalization of the unicode data before use # <<<<<<<<<<<<<<
  7461. * modified_text_list.append(norm_line)
  7462. * return modified_text_list
  7463. */
  7464. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_unicodedata, __pyx_n_s_normalize); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7465. __Pyx_GOTREF(__pyx_t_7);
  7466. __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7467. __Pyx_GOTREF(__pyx_t_5);
  7468. __Pyx_INCREF(__pyx_n_s_NFKD);
  7469. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_NFKD);
  7470. __Pyx_GIVEREF(__pyx_n_s_NFKD);
  7471. __Pyx_INCREF(__pyx_v_line);
  7472. PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_line);
  7473. __Pyx_GIVEREF(__pyx_v_line);
  7474. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7475. __Pyx_GOTREF(__pyx_t_4);
  7476. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7477. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7478. __Pyx_XDECREF_SET(__pyx_v_norm_line, __pyx_t_4);
  7479. __pyx_t_4 = 0;
  7480. /* "lib/Naked/toolshed/c/file.pyx":314
  7481. * import unicodedata
  7482. * norm_line = unicodedata.normalize('NFKD', line) # NKFD normalization of the unicode data before use
  7483. * modified_text_list.append(norm_line) # <<<<<<<<<<<<<<
  7484. * return modified_text_list
  7485. * except Exception as e:
  7486. */
  7487. __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_modified_text_list, __pyx_v_norm_line); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7488. }
  7489. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7490. /* "lib/Naked/toolshed/c/file.pyx":315
  7491. * norm_line = unicodedata.normalize('NFKD', line) # NKFD normalization of the unicode data before use
  7492. * modified_text_list.append(norm_line)
  7493. * return modified_text_list # <<<<<<<<<<<<<<
  7494. * except Exception as e:
  7495. * if DEBUG_FLAG:
  7496. */
  7497. __Pyx_XDECREF(__pyx_r);
  7498. __Pyx_INCREF(__pyx_v_modified_text_list);
  7499. __pyx_r = __pyx_v_modified_text_list;
  7500. goto __pyx_L21_try_return;
  7501. }
  7502. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  7503. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  7504. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  7505. goto __pyx_L24_try_end;
  7506. __pyx_L17_error:;
  7507. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7508. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  7509. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7510. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  7511. /* "lib/Naked/toolshed/c/file.pyx":309
  7512. * try:
  7513. * import codecs
  7514. * with codecs.open(self.filepath, encoding='utf-8', mode='r') as uni_reader: # <<<<<<<<<<<<<<
  7515. * modified_text_list = []
  7516. * for line in uni_reader:
  7517. */
  7518. /*except:*/ {
  7519. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.readlines_utf8", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7520. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_4, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  7521. __Pyx_GOTREF(__pyx_t_6);
  7522. __Pyx_GOTREF(__pyx_t_4);
  7523. __Pyx_GOTREF(__pyx_t_5);
  7524. __pyx_t_7 = PyTuple_Pack(3, __pyx_t_6, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  7525. __Pyx_GOTREF(__pyx_t_7);
  7526. __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_7, NULL);
  7527. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7528. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7529. if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  7530. __Pyx_GOTREF(__pyx_t_15);
  7531. __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_15);
  7532. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  7533. if (__pyx_t_16 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  7534. __pyx_t_17 = ((!(__pyx_t_16 != 0)) != 0);
  7535. if (__pyx_t_17) {
  7536. __Pyx_GIVEREF(__pyx_t_6);
  7537. __Pyx_GIVEREF(__pyx_t_4);
  7538. __Pyx_XGIVEREF(__pyx_t_5);
  7539. __Pyx_ErrRestore(__pyx_t_6, __pyx_t_4, __pyx_t_5);
  7540. __pyx_t_6 = 0; __pyx_t_4 = 0; __pyx_t_5 = 0;
  7541. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  7542. }
  7543. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7544. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7545. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7546. goto __pyx_L18_exception_handled;
  7547. }
  7548. __pyx_L19_except_error:;
  7549. __Pyx_XGIVEREF(__pyx_t_9);
  7550. __Pyx_XGIVEREF(__pyx_t_10);
  7551. __Pyx_XGIVEREF(__pyx_t_11);
  7552. __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
  7553. goto __pyx_L3_error;
  7554. __pyx_L21_try_return:;
  7555. __Pyx_XGIVEREF(__pyx_t_9);
  7556. __Pyx_XGIVEREF(__pyx_t_10);
  7557. __Pyx_XGIVEREF(__pyx_t_11);
  7558. __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
  7559. goto __pyx_L14_return;
  7560. __pyx_L18_exception_handled:;
  7561. __Pyx_XGIVEREF(__pyx_t_9);
  7562. __Pyx_XGIVEREF(__pyx_t_10);
  7563. __Pyx_XGIVEREF(__pyx_t_11);
  7564. __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
  7565. __pyx_L24_try_end:;
  7566. }
  7567. }
  7568. /*finally:*/ {
  7569. /*normal exit:*/{
  7570. if (__pyx_t_8) {
  7571. __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__37, NULL);
  7572. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7573. if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7574. __Pyx_GOTREF(__pyx_t_11);
  7575. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  7576. }
  7577. goto __pyx_L16;
  7578. }
  7579. __pyx_L14_return: {
  7580. __pyx_t_11 = __pyx_r;
  7581. __pyx_r = 0;
  7582. if (__pyx_t_8) {
  7583. __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__38, NULL);
  7584. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7585. if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7586. __Pyx_GOTREF(__pyx_t_10);
  7587. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  7588. }
  7589. __pyx_r = __pyx_t_11;
  7590. __pyx_t_11 = 0;
  7591. goto __pyx_L7_try_return;
  7592. }
  7593. __pyx_L16:;
  7594. }
  7595. goto __pyx_L31;
  7596. __pyx_L11_error:;
  7597. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7598. goto __pyx_L3_error;
  7599. __pyx_L31:;
  7600. }
  7601. }
  7602. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  7603. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  7604. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  7605. goto __pyx_L10_try_end;
  7606. __pyx_L3_error:;
  7607. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7608. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  7609. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7610. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  7611. /* "lib/Naked/toolshed/c/file.pyx":316
  7612. * modified_text_list.append(norm_line)
  7613. * return modified_text_list
  7614. * except Exception as e: # <<<<<<<<<<<<<<
  7615. * if DEBUG_FLAG:
  7616. * sys.stderr.write("Naked Framework Error: unable to read lines in the unicode file with the readlines_utf8 method (Naked.toolshed.file.py)")
  7617. */
  7618. __pyx_t_18 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  7619. if (__pyx_t_18) {
  7620. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.readlines_utf8", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7621. if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  7622. __Pyx_GOTREF(__pyx_t_5);
  7623. __Pyx_GOTREF(__pyx_t_4);
  7624. __Pyx_GOTREF(__pyx_t_6);
  7625. __Pyx_INCREF(__pyx_t_4);
  7626. __pyx_v_e = __pyx_t_4;
  7627. /* "lib/Naked/toolshed/c/file.pyx":317
  7628. * return modified_text_list
  7629. * except Exception as e:
  7630. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  7631. * sys.stderr.write("Naked Framework Error: unable to read lines in the unicode file with the readlines_utf8 method (Naked.toolshed.file.py)")
  7632. * raise e
  7633. */
  7634. __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  7635. __Pyx_GOTREF(__pyx_t_7);
  7636. __pyx_t_17 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_17 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  7637. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7638. if (__pyx_t_17) {
  7639. /* "lib/Naked/toolshed/c/file.pyx":318
  7640. * except Exception as e:
  7641. * if DEBUG_FLAG:
  7642. * sys.stderr.write("Naked Framework Error: unable to read lines in the unicode file with the readlines_utf8 method (Naked.toolshed.file.py)") # <<<<<<<<<<<<<<
  7643. * raise e
  7644. *
  7645. */
  7646. __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  7647. __Pyx_GOTREF(__pyx_t_7);
  7648. __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_stderr); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  7649. __Pyx_GOTREF(__pyx_t_19);
  7650. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7651. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_n_s_write); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  7652. __Pyx_GOTREF(__pyx_t_7);
  7653. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  7654. __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  7655. __Pyx_GOTREF(__pyx_t_19);
  7656. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7657. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  7658. goto __pyx_L34;
  7659. }
  7660. __pyx_L34:;
  7661. /* "lib/Naked/toolshed/c/file.pyx":319
  7662. * if DEBUG_FLAG:
  7663. * sys.stderr.write("Naked Framework Error: unable to read lines in the unicode file with the readlines_utf8 method (Naked.toolshed.file.py)")
  7664. * raise e # <<<<<<<<<<<<<<
  7665. *
  7666. * #------------------------------------------------------------------------------
  7667. */
  7668. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  7669. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  7670. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7671. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7672. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7673. goto __pyx_L4_exception_handled;
  7674. }
  7675. goto __pyx_L5_except_error;
  7676. __pyx_L5_except_error:;
  7677. __Pyx_XGIVEREF(__pyx_t_1);
  7678. __Pyx_XGIVEREF(__pyx_t_2);
  7679. __Pyx_XGIVEREF(__pyx_t_3);
  7680. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  7681. goto __pyx_L1_error;
  7682. __pyx_L7_try_return:;
  7683. __Pyx_XGIVEREF(__pyx_t_1);
  7684. __Pyx_XGIVEREF(__pyx_t_2);
  7685. __Pyx_XGIVEREF(__pyx_t_3);
  7686. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  7687. goto __pyx_L0;
  7688. __pyx_L4_exception_handled:;
  7689. __Pyx_XGIVEREF(__pyx_t_1);
  7690. __Pyx_XGIVEREF(__pyx_t_2);
  7691. __Pyx_XGIVEREF(__pyx_t_3);
  7692. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  7693. __pyx_L10_try_end:;
  7694. }
  7695. /* "lib/Naked/toolshed/c/file.pyx":306
  7696. * # Tests: test_IO.py :: test_file_readlines_unicode, test_file_readlines_utf8_missing_file
  7697. * #------------------------------------------------------------------------------
  7698. * def readlines_utf8(self): # <<<<<<<<<<<<<<
  7699. * try:
  7700. * import codecs
  7701. */
  7702. /* function exit code */
  7703. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  7704. goto __pyx_L0;
  7705. __pyx_L1_error:;
  7706. __Pyx_XDECREF(__pyx_t_4);
  7707. __Pyx_XDECREF(__pyx_t_5);
  7708. __Pyx_XDECREF(__pyx_t_6);
  7709. __Pyx_XDECREF(__pyx_t_7);
  7710. __Pyx_XDECREF(__pyx_t_19);
  7711. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.readlines_utf8", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7712. __pyx_r = NULL;
  7713. __pyx_L0:;
  7714. __Pyx_XDECREF(__pyx_v_codecs);
  7715. __Pyx_XDECREF(__pyx_v_uni_reader);
  7716. __Pyx_XDECREF(__pyx_v_modified_text_list);
  7717. __Pyx_XDECREF(__pyx_v_line);
  7718. __Pyx_XDECREF(__pyx_v_unicodedata);
  7719. __Pyx_XDECREF(__pyx_v_norm_line);
  7720. __Pyx_XDECREF(__pyx_v_e);
  7721. __Pyx_XGIVEREF(__pyx_r);
  7722. __Pyx_RefNannyFinishContext();
  7723. return __pyx_r;
  7724. }
  7725. /* "lib/Naked/toolshed/c/file.pyx":329
  7726. * # test_file_read_gzip_missing_file
  7727. * #------------------------------------------------------------------------------
  7728. * def read_gzip(self, encoding="system_default"): # <<<<<<<<<<<<<<
  7729. * try:
  7730. * import gzip
  7731. */
  7732. /* Python wrapper */
  7733. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_15read_gzip(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  7734. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileReader_15read_gzip = {__Pyx_NAMESTR("read_gzip"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_15read_gzip, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  7735. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_15read_gzip(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  7736. PyObject *__pyx_v_self = 0;
  7737. PyObject *__pyx_v_encoding = 0;
  7738. int __pyx_lineno = 0;
  7739. const char *__pyx_filename = NULL;
  7740. int __pyx_clineno = 0;
  7741. PyObject *__pyx_r = 0;
  7742. __Pyx_RefNannyDeclarations
  7743. __Pyx_RefNannySetupContext("read_gzip (wrapper)", 0);
  7744. {
  7745. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_encoding,0};
  7746. PyObject* values[2] = {0,0};
  7747. values[1] = ((PyObject *)((PyObject*)__pyx_n_s_system_default));
  7748. if (unlikely(__pyx_kwds)) {
  7749. Py_ssize_t kw_args;
  7750. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  7751. switch (pos_args) {
  7752. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  7753. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  7754. case 0: break;
  7755. default: goto __pyx_L5_argtuple_error;
  7756. }
  7757. kw_args = PyDict_Size(__pyx_kwds);
  7758. switch (pos_args) {
  7759. case 0:
  7760. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
  7761. else goto __pyx_L5_argtuple_error;
  7762. case 1:
  7763. if (kw_args > 0) {
  7764. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_encoding);
  7765. if (value) { values[1] = value; kw_args--; }
  7766. }
  7767. }
  7768. if (unlikely(kw_args > 0)) {
  7769. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read_gzip") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7770. }
  7771. } else {
  7772. switch (PyTuple_GET_SIZE(__pyx_args)) {
  7773. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  7774. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  7775. break;
  7776. default: goto __pyx_L5_argtuple_error;
  7777. }
  7778. }
  7779. __pyx_v_self = values[0];
  7780. __pyx_v_encoding = values[1];
  7781. }
  7782. goto __pyx_L4_argument_unpacking_done;
  7783. __pyx_L5_argtuple_error:;
  7784. __Pyx_RaiseArgtupleInvalid("read_gzip", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7785. __pyx_L3_error:;
  7786. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.read_gzip", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7787. __Pyx_RefNannyFinishContext();
  7788. return NULL;
  7789. __pyx_L4_argument_unpacking_done:;
  7790. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_14read_gzip(__pyx_self, __pyx_v_self, __pyx_v_encoding);
  7791. /* function exit code */
  7792. __Pyx_RefNannyFinishContext();
  7793. return __pyx_r;
  7794. }
  7795. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_14read_gzip(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_encoding) {
  7796. PyObject *__pyx_v_gzip = NULL;
  7797. PyObject *__pyx_v_gzip_reader = NULL;
  7798. PyObject *__pyx_v_file_data = NULL;
  7799. PyObject *__pyx_v_codecs = NULL;
  7800. PyObject *__pyx_v_unicodedata = NULL;
  7801. PyObject *__pyx_v_norm_data = NULL;
  7802. PyObject *__pyx_v_e = NULL;
  7803. PyObject *__pyx_r = NULL;
  7804. __Pyx_RefNannyDeclarations
  7805. PyObject *__pyx_t_1 = NULL;
  7806. PyObject *__pyx_t_2 = NULL;
  7807. PyObject *__pyx_t_3 = NULL;
  7808. PyObject *__pyx_t_4 = NULL;
  7809. PyObject *__pyx_t_5 = NULL;
  7810. PyObject *__pyx_t_6 = NULL;
  7811. PyObject *__pyx_t_7 = NULL;
  7812. PyObject *__pyx_t_8 = NULL;
  7813. PyObject *__pyx_t_9 = NULL;
  7814. PyObject *__pyx_t_10 = NULL;
  7815. int __pyx_t_11;
  7816. int __pyx_t_12;
  7817. int __pyx_t_13;
  7818. PyObject *__pyx_t_14 = NULL;
  7819. PyObject *__pyx_t_15 = NULL;
  7820. int __pyx_t_16;
  7821. PyObject *__pyx_t_17 = NULL;
  7822. int __pyx_lineno = 0;
  7823. const char *__pyx_filename = NULL;
  7824. int __pyx_clineno = 0;
  7825. __Pyx_RefNannySetupContext("read_gzip", 0);
  7826. /* "lib/Naked/toolshed/c/file.pyx":330
  7827. * #------------------------------------------------------------------------------
  7828. * def read_gzip(self, encoding="system_default"):
  7829. * try: # <<<<<<<<<<<<<<
  7830. * import gzip
  7831. * with gzip.open(self.filepath, 'rb') as gzip_reader:
  7832. */
  7833. {
  7834. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  7835. __Pyx_XGOTREF(__pyx_t_1);
  7836. __Pyx_XGOTREF(__pyx_t_2);
  7837. __Pyx_XGOTREF(__pyx_t_3);
  7838. /*try:*/ {
  7839. /* "lib/Naked/toolshed/c/file.pyx":331
  7840. * def read_gzip(self, encoding="system_default"):
  7841. * try:
  7842. * import gzip # <<<<<<<<<<<<<<
  7843. * with gzip.open(self.filepath, 'rb') as gzip_reader:
  7844. * file_data = gzip_reader.read()
  7845. */
  7846. __pyx_t_4 = __Pyx_Import(__pyx_n_s_gzip, 0, -1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7847. __Pyx_GOTREF(__pyx_t_4);
  7848. __pyx_v_gzip = __pyx_t_4;
  7849. __pyx_t_4 = 0;
  7850. /* "lib/Naked/toolshed/c/file.pyx":332
  7851. * try:
  7852. * import gzip
  7853. * with gzip.open(self.filepath, 'rb') as gzip_reader: # <<<<<<<<<<<<<<
  7854. * file_data = gzip_reader.read()
  7855. * if encoding in ["utf-8", "utf8", "utf_8", "UTF-8", "UTF8", "UTF_8"]:
  7856. */
  7857. /*with:*/ {
  7858. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_gzip, __pyx_n_s_open); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7859. __Pyx_GOTREF(__pyx_t_4);
  7860. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7861. __Pyx_GOTREF(__pyx_t_5);
  7862. __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7863. __Pyx_GOTREF(__pyx_t_6);
  7864. PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
  7865. __Pyx_GIVEREF(__pyx_t_5);
  7866. __Pyx_INCREF(__pyx_n_s_rb);
  7867. PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_rb);
  7868. __Pyx_GIVEREF(__pyx_n_s_rb);
  7869. __pyx_t_5 = 0;
  7870. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7871. __Pyx_GOTREF(__pyx_t_5);
  7872. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7873. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7874. __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_t_5, __pyx_n_s_exit); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  7875. __Pyx_GOTREF(__pyx_t_7);
  7876. __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_5, __pyx_n_s_enter); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
  7877. __Pyx_GOTREF(__pyx_t_6);
  7878. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
  7879. __Pyx_GOTREF(__pyx_t_4);
  7880. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7881. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7882. /*try:*/ {
  7883. {
  7884. __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
  7885. __Pyx_XGOTREF(__pyx_t_8);
  7886. __Pyx_XGOTREF(__pyx_t_9);
  7887. __Pyx_XGOTREF(__pyx_t_10);
  7888. /*try:*/ {
  7889. __Pyx_INCREF(__pyx_t_4);
  7890. __pyx_v_gzip_reader = __pyx_t_4;
  7891. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7892. /* "lib/Naked/toolshed/c/file.pyx":333
  7893. * import gzip
  7894. * with gzip.open(self.filepath, 'rb') as gzip_reader:
  7895. * file_data = gzip_reader.read() # <<<<<<<<<<<<<<
  7896. * if encoding in ["utf-8", "utf8", "utf_8", "UTF-8", "UTF8", "UTF_8"]:
  7897. * import codecs
  7898. */
  7899. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_gzip_reader, __pyx_n_s_read); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7900. __Pyx_GOTREF(__pyx_t_4);
  7901. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7902. __Pyx_GOTREF(__pyx_t_5);
  7903. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7904. __pyx_v_file_data = __pyx_t_5;
  7905. __pyx_t_5 = 0;
  7906. /* "lib/Naked/toolshed/c/file.pyx":334
  7907. * with gzip.open(self.filepath, 'rb') as gzip_reader:
  7908. * file_data = gzip_reader.read()
  7909. * if encoding in ["utf-8", "utf8", "utf_8", "UTF-8", "UTF8", "UTF_8"]: # <<<<<<<<<<<<<<
  7910. * import codecs
  7911. * file_data = codecs.decode(file_data, "utf-8")
  7912. */
  7913. __Pyx_INCREF(__pyx_v_encoding);
  7914. __pyx_t_5 = __pyx_v_encoding;
  7915. __pyx_t_11 = (__Pyx_PyString_Equals(__pyx_t_5, __pyx_kp_s_utf_8_2, Py_EQ)); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7916. if (!__pyx_t_11) {
  7917. __pyx_t_12 = (__Pyx_PyString_Equals(__pyx_t_5, __pyx_n_s_utf8, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7918. __pyx_t_13 = __pyx_t_12;
  7919. } else {
  7920. __pyx_t_13 = __pyx_t_11;
  7921. }
  7922. if (!__pyx_t_13) {
  7923. __pyx_t_11 = (__Pyx_PyString_Equals(__pyx_t_5, __pyx_n_s_utf_8, Py_EQ)); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7924. __pyx_t_12 = __pyx_t_11;
  7925. } else {
  7926. __pyx_t_12 = __pyx_t_13;
  7927. }
  7928. if (!__pyx_t_12) {
  7929. __pyx_t_13 = (__Pyx_PyString_Equals(__pyx_t_5, __pyx_kp_s_UTF_8, Py_EQ)); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7930. __pyx_t_11 = __pyx_t_13;
  7931. } else {
  7932. __pyx_t_11 = __pyx_t_12;
  7933. }
  7934. if (!__pyx_t_11) {
  7935. __pyx_t_12 = (__Pyx_PyString_Equals(__pyx_t_5, __pyx_n_s_UTF8, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7936. __pyx_t_13 = __pyx_t_12;
  7937. } else {
  7938. __pyx_t_13 = __pyx_t_11;
  7939. }
  7940. if (!__pyx_t_13) {
  7941. __pyx_t_11 = (__Pyx_PyString_Equals(__pyx_t_5, __pyx_n_s_UTF_8_2, Py_EQ)); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7942. __pyx_t_12 = __pyx_t_11;
  7943. } else {
  7944. __pyx_t_12 = __pyx_t_13;
  7945. }
  7946. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7947. __pyx_t_13 = (__pyx_t_12 != 0);
  7948. if (__pyx_t_13) {
  7949. /* "lib/Naked/toolshed/c/file.pyx":335
  7950. * file_data = gzip_reader.read()
  7951. * if encoding in ["utf-8", "utf8", "utf_8", "UTF-8", "UTF8", "UTF_8"]:
  7952. * import codecs # <<<<<<<<<<<<<<
  7953. * file_data = codecs.decode(file_data, "utf-8")
  7954. * import unicodedata
  7955. */
  7956. __pyx_t_5 = __Pyx_Import(__pyx_n_s_codecs, 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7957. __Pyx_GOTREF(__pyx_t_5);
  7958. __pyx_v_codecs = __pyx_t_5;
  7959. __pyx_t_5 = 0;
  7960. /* "lib/Naked/toolshed/c/file.pyx":336
  7961. * if encoding in ["utf-8", "utf8", "utf_8", "UTF-8", "UTF8", "UTF_8"]:
  7962. * import codecs
  7963. * file_data = codecs.decode(file_data, "utf-8") # <<<<<<<<<<<<<<
  7964. * import unicodedata
  7965. * norm_data = unicodedata.normalize('NFKD', file_data) # NKFD normalization of the unicode data before passing back to the caller
  7966. */
  7967. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_codecs, __pyx_n_s_decode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7968. __Pyx_GOTREF(__pyx_t_5);
  7969. __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7970. __Pyx_GOTREF(__pyx_t_4);
  7971. __Pyx_INCREF(__pyx_v_file_data);
  7972. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_file_data);
  7973. __Pyx_GIVEREF(__pyx_v_file_data);
  7974. __Pyx_INCREF(__pyx_kp_s_utf_8_2);
  7975. PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_kp_s_utf_8_2);
  7976. __Pyx_GIVEREF(__pyx_kp_s_utf_8_2);
  7977. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7978. __Pyx_GOTREF(__pyx_t_6);
  7979. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7980. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7981. __Pyx_DECREF_SET(__pyx_v_file_data, __pyx_t_6);
  7982. __pyx_t_6 = 0;
  7983. /* "lib/Naked/toolshed/c/file.pyx":337
  7984. * import codecs
  7985. * file_data = codecs.decode(file_data, "utf-8")
  7986. * import unicodedata # <<<<<<<<<<<<<<
  7987. * norm_data = unicodedata.normalize('NFKD', file_data) # NKFD normalization of the unicode data before passing back to the caller
  7988. * return norm_data
  7989. */
  7990. __pyx_t_6 = __Pyx_Import(__pyx_n_s_unicodedata, 0, -1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  7991. __Pyx_GOTREF(__pyx_t_6);
  7992. __pyx_v_unicodedata = __pyx_t_6;
  7993. __pyx_t_6 = 0;
  7994. /* "lib/Naked/toolshed/c/file.pyx":338
  7995. * file_data = codecs.decode(file_data, "utf-8")
  7996. * import unicodedata
  7997. * norm_data = unicodedata.normalize('NFKD', file_data) # NKFD normalization of the unicode data before passing back to the caller # <<<<<<<<<<<<<<
  7998. * return norm_data
  7999. * else:
  8000. */
  8001. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_unicodedata, __pyx_n_s_normalize); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  8002. __Pyx_GOTREF(__pyx_t_6);
  8003. __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  8004. __Pyx_GOTREF(__pyx_t_4);
  8005. __Pyx_INCREF(__pyx_n_s_NFKD);
  8006. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_NFKD);
  8007. __Pyx_GIVEREF(__pyx_n_s_NFKD);
  8008. __Pyx_INCREF(__pyx_v_file_data);
  8009. PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_file_data);
  8010. __Pyx_GIVEREF(__pyx_v_file_data);
  8011. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  8012. __Pyx_GOTREF(__pyx_t_5);
  8013. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8014. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8015. __pyx_v_norm_data = __pyx_t_5;
  8016. __pyx_t_5 = 0;
  8017. /* "lib/Naked/toolshed/c/file.pyx":339
  8018. * import unicodedata
  8019. * norm_data = unicodedata.normalize('NFKD', file_data) # NKFD normalization of the unicode data before passing back to the caller
  8020. * return norm_data # <<<<<<<<<<<<<<
  8021. * else:
  8022. * return file_data
  8023. */
  8024. __Pyx_XDECREF(__pyx_r);
  8025. __Pyx_INCREF(__pyx_v_norm_data);
  8026. __pyx_r = __pyx_v_norm_data;
  8027. goto __pyx_L21_try_return;
  8028. }
  8029. /*else*/ {
  8030. /* "lib/Naked/toolshed/c/file.pyx":341
  8031. * return norm_data
  8032. * else:
  8033. * return file_data # <<<<<<<<<<<<<<
  8034. * except Exception as e:
  8035. * if DEBUG_FLAG:
  8036. */
  8037. __Pyx_XDECREF(__pyx_r);
  8038. __Pyx_INCREF(__pyx_v_file_data);
  8039. __pyx_r = __pyx_v_file_data;
  8040. goto __pyx_L21_try_return;
  8041. }
  8042. }
  8043. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  8044. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  8045. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  8046. goto __pyx_L24_try_end;
  8047. __pyx_L17_error:;
  8048. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  8049. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  8050. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  8051. /* "lib/Naked/toolshed/c/file.pyx":332
  8052. * try:
  8053. * import gzip
  8054. * with gzip.open(self.filepath, 'rb') as gzip_reader: # <<<<<<<<<<<<<<
  8055. * file_data = gzip_reader.read()
  8056. * if encoding in ["utf-8", "utf8", "utf_8", "UTF-8", "UTF8", "UTF_8"]:
  8057. */
  8058. /*except:*/ {
  8059. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.read_gzip", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8060. if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  8061. __Pyx_GOTREF(__pyx_t_5);
  8062. __Pyx_GOTREF(__pyx_t_4);
  8063. __Pyx_GOTREF(__pyx_t_6);
  8064. __pyx_t_14 = PyTuple_Pack(3, __pyx_t_5, __pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  8065. __Pyx_GOTREF(__pyx_t_14);
  8066. __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_14, NULL);
  8067. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  8068. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  8069. if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  8070. __Pyx_GOTREF(__pyx_t_15);
  8071. __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_15);
  8072. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  8073. if (__pyx_t_13 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  8074. __pyx_t_12 = ((!(__pyx_t_13 != 0)) != 0);
  8075. if (__pyx_t_12) {
  8076. __Pyx_GIVEREF(__pyx_t_5);
  8077. __Pyx_GIVEREF(__pyx_t_4);
  8078. __Pyx_XGIVEREF(__pyx_t_6);
  8079. __Pyx_ErrRestore(__pyx_t_5, __pyx_t_4, __pyx_t_6);
  8080. __pyx_t_5 = 0; __pyx_t_4 = 0; __pyx_t_6 = 0;
  8081. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  8082. }
  8083. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  8084. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8085. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8086. goto __pyx_L18_exception_handled;
  8087. }
  8088. __pyx_L19_except_error:;
  8089. __Pyx_XGIVEREF(__pyx_t_8);
  8090. __Pyx_XGIVEREF(__pyx_t_9);
  8091. __Pyx_XGIVEREF(__pyx_t_10);
  8092. __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
  8093. goto __pyx_L3_error;
  8094. __pyx_L21_try_return:;
  8095. __Pyx_XGIVEREF(__pyx_t_8);
  8096. __Pyx_XGIVEREF(__pyx_t_9);
  8097. __Pyx_XGIVEREF(__pyx_t_10);
  8098. __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
  8099. goto __pyx_L14_return;
  8100. __pyx_L18_exception_handled:;
  8101. __Pyx_XGIVEREF(__pyx_t_8);
  8102. __Pyx_XGIVEREF(__pyx_t_9);
  8103. __Pyx_XGIVEREF(__pyx_t_10);
  8104. __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
  8105. __pyx_L24_try_end:;
  8106. }
  8107. }
  8108. /*finally:*/ {
  8109. /*normal exit:*/{
  8110. if (__pyx_t_7) {
  8111. __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__40, NULL);
  8112. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  8113. if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  8114. __Pyx_GOTREF(__pyx_t_10);
  8115. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  8116. }
  8117. goto __pyx_L16;
  8118. }
  8119. __pyx_L14_return: {
  8120. __pyx_t_10 = __pyx_r;
  8121. __pyx_r = 0;
  8122. if (__pyx_t_7) {
  8123. __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__41, NULL);
  8124. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  8125. if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  8126. __Pyx_GOTREF(__pyx_t_9);
  8127. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  8128. }
  8129. __pyx_r = __pyx_t_10;
  8130. __pyx_t_10 = 0;
  8131. goto __pyx_L7_try_return;
  8132. }
  8133. __pyx_L16:;
  8134. }
  8135. goto __pyx_L30;
  8136. __pyx_L11_error:;
  8137. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  8138. goto __pyx_L3_error;
  8139. __pyx_L30:;
  8140. }
  8141. }
  8142. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  8143. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  8144. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  8145. goto __pyx_L10_try_end;
  8146. __pyx_L3_error:;
  8147. __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  8148. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  8149. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  8150. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  8151. /* "lib/Naked/toolshed/c/file.pyx":342
  8152. * else:
  8153. * return file_data
  8154. * except Exception as e: # <<<<<<<<<<<<<<
  8155. * if DEBUG_FLAG:
  8156. * sys.stderr.write("Naked Framework Error: Unable to read from the gzip compressed file with the read_gzip() method (Naked.toolshed.file.py).")
  8157. */
  8158. __pyx_t_16 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  8159. if (__pyx_t_16) {
  8160. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.read_gzip", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8161. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_4, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  8162. __Pyx_GOTREF(__pyx_t_6);
  8163. __Pyx_GOTREF(__pyx_t_4);
  8164. __Pyx_GOTREF(__pyx_t_5);
  8165. __Pyx_INCREF(__pyx_t_4);
  8166. __pyx_v_e = __pyx_t_4;
  8167. /* "lib/Naked/toolshed/c/file.pyx":343
  8168. * return file_data
  8169. * except Exception as e:
  8170. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  8171. * sys.stderr.write("Naked Framework Error: Unable to read from the gzip compressed file with the read_gzip() method (Naked.toolshed.file.py).")
  8172. * raise e
  8173. */
  8174. __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  8175. __Pyx_GOTREF(__pyx_t_14);
  8176. __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  8177. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  8178. if (__pyx_t_12) {
  8179. /* "lib/Naked/toolshed/c/file.pyx":344
  8180. * except Exception as e:
  8181. * if DEBUG_FLAG:
  8182. * sys.stderr.write("Naked Framework Error: Unable to read from the gzip compressed file with the read_gzip() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  8183. * raise e
  8184. *
  8185. */
  8186. __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  8187. __Pyx_GOTREF(__pyx_t_14);
  8188. __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_stderr); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  8189. __Pyx_GOTREF(__pyx_t_17);
  8190. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  8191. __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_write); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  8192. __Pyx_GOTREF(__pyx_t_14);
  8193. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  8194. __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  8195. __Pyx_GOTREF(__pyx_t_17);
  8196. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  8197. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  8198. goto __pyx_L33;
  8199. }
  8200. __pyx_L33:;
  8201. /* "lib/Naked/toolshed/c/file.pyx":345
  8202. * if DEBUG_FLAG:
  8203. * sys.stderr.write("Naked Framework Error: Unable to read from the gzip compressed file with the read_gzip() method (Naked.toolshed.file.py).")
  8204. * raise e # <<<<<<<<<<<<<<
  8205. *
  8206. * #------------------------------------------------------------------------------
  8207. */
  8208. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  8209. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  8210. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8211. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8212. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  8213. goto __pyx_L4_exception_handled;
  8214. }
  8215. goto __pyx_L5_except_error;
  8216. __pyx_L5_except_error:;
  8217. __Pyx_XGIVEREF(__pyx_t_1);
  8218. __Pyx_XGIVEREF(__pyx_t_2);
  8219. __Pyx_XGIVEREF(__pyx_t_3);
  8220. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  8221. goto __pyx_L1_error;
  8222. __pyx_L7_try_return:;
  8223. __Pyx_XGIVEREF(__pyx_t_1);
  8224. __Pyx_XGIVEREF(__pyx_t_2);
  8225. __Pyx_XGIVEREF(__pyx_t_3);
  8226. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  8227. goto __pyx_L0;
  8228. __pyx_L4_exception_handled:;
  8229. __Pyx_XGIVEREF(__pyx_t_1);
  8230. __Pyx_XGIVEREF(__pyx_t_2);
  8231. __Pyx_XGIVEREF(__pyx_t_3);
  8232. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  8233. __pyx_L10_try_end:;
  8234. }
  8235. /* "lib/Naked/toolshed/c/file.pyx":329
  8236. * # test_file_read_gzip_missing_file
  8237. * #------------------------------------------------------------------------------
  8238. * def read_gzip(self, encoding="system_default"): # <<<<<<<<<<<<<<
  8239. * try:
  8240. * import gzip
  8241. */
  8242. /* function exit code */
  8243. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  8244. goto __pyx_L0;
  8245. __pyx_L1_error:;
  8246. __Pyx_XDECREF(__pyx_t_4);
  8247. __Pyx_XDECREF(__pyx_t_5);
  8248. __Pyx_XDECREF(__pyx_t_6);
  8249. __Pyx_XDECREF(__pyx_t_14);
  8250. __Pyx_XDECREF(__pyx_t_17);
  8251. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.read_gzip", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8252. __pyx_r = NULL;
  8253. __pyx_L0:;
  8254. __Pyx_XDECREF(__pyx_v_gzip);
  8255. __Pyx_XDECREF(__pyx_v_gzip_reader);
  8256. __Pyx_XDECREF(__pyx_v_file_data);
  8257. __Pyx_XDECREF(__pyx_v_codecs);
  8258. __Pyx_XDECREF(__pyx_v_unicodedata);
  8259. __Pyx_XDECREF(__pyx_v_norm_data);
  8260. __Pyx_XDECREF(__pyx_v_e);
  8261. __Pyx_XGIVEREF(__pyx_r);
  8262. __Pyx_RefNannyFinishContext();
  8263. return __pyx_r;
  8264. }
  8265. /* "lib/Naked/toolshed/c/file.pyx":355
  8266. * # test_file_read_utf8_missing_file
  8267. * #------------------------------------------------------------------------------
  8268. * def read_utf8(self): # <<<<<<<<<<<<<<
  8269. * try:
  8270. * import codecs
  8271. */
  8272. /* Python wrapper */
  8273. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_17read_utf8(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
  8274. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileReader_17read_utf8 = {__Pyx_NAMESTR("read_utf8"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_17read_utf8, METH_O, __Pyx_DOCSTR(0)};
  8275. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_4file_10FileReader_17read_utf8(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  8276. PyObject *__pyx_r = 0;
  8277. __Pyx_RefNannyDeclarations
  8278. __Pyx_RefNannySetupContext("read_utf8 (wrapper)", 0);
  8279. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_16read_utf8(__pyx_self, ((PyObject *)__pyx_v_self));
  8280. /* function exit code */
  8281. __Pyx_RefNannyFinishContext();
  8282. return __pyx_r;
  8283. }
  8284. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_4file_10FileReader_16read_utf8(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  8285. PyObject *__pyx_v_codecs = NULL;
  8286. PyObject *__pyx_v_f = NULL;
  8287. PyObject *__pyx_v_ioe = NULL;
  8288. PyObject *__pyx_v_textstring = NULL;
  8289. PyObject *__pyx_v_unicodedata = NULL;
  8290. PyObject *__pyx_v_norm_text = NULL;
  8291. PyObject *__pyx_v_e = NULL;
  8292. PyObject *__pyx_r = NULL;
  8293. __Pyx_RefNannyDeclarations
  8294. PyObject *__pyx_t_1 = NULL;
  8295. PyObject *__pyx_t_2 = NULL;
  8296. PyObject *__pyx_t_3 = NULL;
  8297. PyObject *__pyx_t_4 = NULL;
  8298. PyObject *__pyx_t_5 = NULL;
  8299. PyObject *__pyx_t_6 = NULL;
  8300. PyObject *__pyx_t_7 = NULL;
  8301. int __pyx_t_8;
  8302. int __pyx_t_9;
  8303. PyObject *__pyx_t_10 = NULL;
  8304. int __pyx_t_11;
  8305. char const *__pyx_t_12;
  8306. PyObject *__pyx_t_13 = NULL;
  8307. PyObject *__pyx_t_14 = NULL;
  8308. PyObject *__pyx_t_15 = NULL;
  8309. int __pyx_lineno = 0;
  8310. const char *__pyx_filename = NULL;
  8311. int __pyx_clineno = 0;
  8312. __Pyx_RefNannySetupContext("read_utf8", 0);
  8313. /* "lib/Naked/toolshed/c/file.pyx":356
  8314. * #------------------------------------------------------------------------------
  8315. * def read_utf8(self):
  8316. * try: # <<<<<<<<<<<<<<
  8317. * import codecs
  8318. * f = codecs.open(self.filepath, encoding='utf_8', mode='r')
  8319. */
  8320. {
  8321. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  8322. __Pyx_XGOTREF(__pyx_t_1);
  8323. __Pyx_XGOTREF(__pyx_t_2);
  8324. __Pyx_XGOTREF(__pyx_t_3);
  8325. /*try:*/ {
  8326. /* "lib/Naked/toolshed/c/file.pyx":357
  8327. * def read_utf8(self):
  8328. * try:
  8329. * import codecs # <<<<<<<<<<<<<<
  8330. * f = codecs.open(self.filepath, encoding='utf_8', mode='r')
  8331. * except IOError as ioe:
  8332. */
  8333. __pyx_t_4 = __Pyx_Import(__pyx_n_s_codecs, 0, -1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  8334. __Pyx_GOTREF(__pyx_t_4);
  8335. __pyx_v_codecs = __pyx_t_4;
  8336. __pyx_t_4 = 0;
  8337. /* "lib/Naked/toolshed/c/file.pyx":358
  8338. * try:
  8339. * import codecs
  8340. * f = codecs.open(self.filepath, encoding='utf_8', mode='r') # <<<<<<<<<<<<<<
  8341. * except IOError as ioe:
  8342. * if DEBUG_FLAG:
  8343. */
  8344. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_codecs, __pyx_n_s_open); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  8345. __Pyx_GOTREF(__pyx_t_4);
  8346. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filepath); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  8347. __Pyx_GOTREF(__pyx_t_5);
  8348. __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  8349. __Pyx_GOTREF(__pyx_t_6);
  8350. PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
  8351. __Pyx_GIVEREF(__pyx_t_5);
  8352. __pyx_t_5 = 0;
  8353. __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  8354. __Pyx_GOTREF(__pyx_t_5);
  8355. if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_encoding, __pyx_n_s_utf_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  8356. if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_mode, __pyx_n_s_r) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  8357. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  8358. __Pyx_GOTREF(__pyx_t_7);
  8359. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8360. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8361. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  8362. __pyx_v_f = __pyx_t_7;
  8363. __pyx_t_7 = 0;
  8364. }
  8365. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  8366. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  8367. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  8368. goto __pyx_L10_try_end;
  8369. __pyx_L3_error:;
  8370. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  8371. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  8372. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  8373. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  8374. /* "lib/Naked/toolshed/c/file.pyx":359
  8375. * import codecs
  8376. * f = codecs.open(self.filepath, encoding='utf_8', mode='r')
  8377. * except IOError as ioe: # <<<<<<<<<<<<<<
  8378. * if DEBUG_FLAG:
  8379. * sys.stderr.write("Naked Framework Error: Unable to open file for read with read_utf8() method (Naked.toolshed.file.py).")
  8380. */
  8381. __pyx_t_8 = PyErr_ExceptionMatches(__pyx_builtin_IOError);
  8382. if (__pyx_t_8) {
  8383. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.read_utf8", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8384. if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_5, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  8385. __Pyx_GOTREF(__pyx_t_7);
  8386. __Pyx_GOTREF(__pyx_t_5);
  8387. __Pyx_GOTREF(__pyx_t_6);
  8388. __Pyx_INCREF(__pyx_t_5);
  8389. __pyx_v_ioe = __pyx_t_5;
  8390. /* "lib/Naked/toolshed/c/file.pyx":360
  8391. * f = codecs.open(self.filepath, encoding='utf_8', mode='r')
  8392. * except IOError as ioe:
  8393. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  8394. * sys.stderr.write("Naked Framework Error: Unable to open file for read with read_utf8() method (Naked.toolshed.file.py).")
  8395. * raise ioe
  8396. */
  8397. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  8398. __Pyx_GOTREF(__pyx_t_4);
  8399. __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  8400. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8401. if (__pyx_t_9) {
  8402. /* "lib/Naked/toolshed/c/file.pyx":361
  8403. * except IOError as ioe:
  8404. * if DEBUG_FLAG:
  8405. * sys.stderr.write("Naked Framework Error: Unable to open file for read with read_utf8() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  8406. * raise ioe
  8407. * try:
  8408. */
  8409. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  8410. __Pyx_GOTREF(__pyx_t_4);
  8411. __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_stderr); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  8412. __Pyx_GOTREF(__pyx_t_10);
  8413. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8414. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_write); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  8415. __Pyx_GOTREF(__pyx_t_4);
  8416. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  8417. __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  8418. __Pyx_GOTREF(__pyx_t_10);
  8419. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8420. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  8421. goto __pyx_L13;
  8422. }
  8423. __pyx_L13:;
  8424. /* "lib/Naked/toolshed/c/file.pyx":362
  8425. * if DEBUG_FLAG:
  8426. * sys.stderr.write("Naked Framework Error: Unable to open file for read with read_utf8() method (Naked.toolshed.file.py).")
  8427. * raise ioe # <<<<<<<<<<<<<<
  8428. * try:
  8429. * textstring = f.read()
  8430. */
  8431. __Pyx_Raise(__pyx_v_ioe, 0, 0, 0);
  8432. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  8433. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  8434. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  8435. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8436. goto __pyx_L4_exception_handled;
  8437. }
  8438. goto __pyx_L5_except_error;
  8439. __pyx_L5_except_error:;
  8440. __Pyx_XGIVEREF(__pyx_t_1);
  8441. __Pyx_XGIVEREF(__pyx_t_2);
  8442. __Pyx_XGIVEREF(__pyx_t_3);
  8443. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  8444. goto __pyx_L1_error;
  8445. __pyx_L4_exception_handled:;
  8446. __Pyx_XGIVEREF(__pyx_t_1);
  8447. __Pyx_XGIVEREF(__pyx_t_2);
  8448. __Pyx_XGIVEREF(__pyx_t_3);
  8449. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  8450. __pyx_L10_try_end:;
  8451. }
  8452. /* "lib/Naked/toolshed/c/file.pyx":363
  8453. * sys.stderr.write("Naked Framework Error: Unable to open file for read with read_utf8() method (Naked.toolshed.file.py).")
  8454. * raise ioe
  8455. * try: # <<<<<<<<<<<<<<
  8456. * textstring = f.read()
  8457. * import unicodedata
  8458. */
  8459. /*try:*/ {
  8460. {
  8461. __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1);
  8462. __Pyx_XGOTREF(__pyx_t_3);
  8463. __Pyx_XGOTREF(__pyx_t_2);
  8464. __Pyx_XGOTREF(__pyx_t_1);
  8465. /*try:*/ {
  8466. /* "lib/Naked/toolshed/c/file.pyx":364
  8467. * raise ioe
  8468. * try:
  8469. * textstring = f.read() # <<<<<<<<<<<<<<
  8470. * import unicodedata
  8471. * norm_text = unicodedata.normalize('NFKD', textstring) # NKFD normalization of the unicode data before returns
  8472. */
  8473. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  8474. __Pyx_GOTREF(__pyx_t_6);
  8475. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  8476. __Pyx_GOTREF(__pyx_t_5);
  8477. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8478. __pyx_v_textstring = __pyx_t_5;
  8479. __pyx_t_5 = 0;
  8480. /* "lib/Naked/toolshed/c/file.pyx":365
  8481. * try:
  8482. * textstring = f.read()
  8483. * import unicodedata # <<<<<<<<<<<<<<
  8484. * norm_text = unicodedata.normalize('NFKD', textstring) # NKFD normalization of the unicode data before returns
  8485. * return norm_text
  8486. */
  8487. __pyx_t_5 = __Pyx_Import(__pyx_n_s_unicodedata, 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  8488. __Pyx_GOTREF(__pyx_t_5);
  8489. __pyx_v_unicodedata = __pyx_t_5;
  8490. __pyx_t_5 = 0;
  8491. /* "lib/Naked/toolshed/c/file.pyx":366
  8492. * textstring = f.read()
  8493. * import unicodedata
  8494. * norm_text = unicodedata.normalize('NFKD', textstring) # NKFD normalization of the unicode data before returns # <<<<<<<<<<<<<<
  8495. * return norm_text
  8496. * except Exception as e:
  8497. */
  8498. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_unicodedata, __pyx_n_s_normalize); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  8499. __Pyx_GOTREF(__pyx_t_5);
  8500. __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  8501. __Pyx_GOTREF(__pyx_t_6);
  8502. __Pyx_INCREF(__pyx_n_s_NFKD);
  8503. PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_n_s_NFKD);
  8504. __Pyx_GIVEREF(__pyx_n_s_NFKD);
  8505. __Pyx_INCREF(__pyx_v_textstring);
  8506. PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_textstring);
  8507. __Pyx_GIVEREF(__pyx_v_textstring);
  8508. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L17_error;}
  8509. __Pyx_GOTREF(__pyx_t_7);
  8510. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  8511. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8512. __pyx_v_norm_text = __pyx_t_7;
  8513. __pyx_t_7 = 0;
  8514. /* "lib/Naked/toolshed/c/file.pyx":367
  8515. * import unicodedata
  8516. * norm_text = unicodedata.normalize('NFKD', textstring) # NKFD normalization of the unicode data before returns
  8517. * return norm_text # <<<<<<<<<<<<<<
  8518. * except Exception as e:
  8519. * if DEBUG_FLAG:
  8520. */
  8521. __Pyx_XDECREF(__pyx_r);
  8522. __Pyx_INCREF(__pyx_v_norm_text);
  8523. __pyx_r = __pyx_v_norm_text;
  8524. goto __pyx_L21_try_return;
  8525. }
  8526. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  8527. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  8528. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  8529. goto __pyx_L24_try_end;
  8530. __pyx_L17_error:;
  8531. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  8532. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  8533. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  8534. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  8535. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  8536. /* "lib/Naked/toolshed/c/file.pyx":368
  8537. * norm_text = unicodedata.normalize('NFKD', textstring) # NKFD normalization of the unicode data before returns
  8538. * return norm_text
  8539. * except Exception as e: # <<<<<<<<<<<<<<
  8540. * if DEBUG_FLAG:
  8541. * sys.stderr.write("Naked Framework Error: Unable to read the file with UTF-8 encoding using the read_utf8() method (Naked.toolshed.file.py).")
  8542. */
  8543. __pyx_t_8 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  8544. if (__pyx_t_8) {
  8545. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.read_utf8", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8546. if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  8547. __Pyx_GOTREF(__pyx_t_7);
  8548. __Pyx_GOTREF(__pyx_t_6);
  8549. __Pyx_GOTREF(__pyx_t_5);
  8550. __Pyx_INCREF(__pyx_t_6);
  8551. __pyx_v_e = __pyx_t_6;
  8552. /* "lib/Naked/toolshed/c/file.pyx":369
  8553. * return norm_text
  8554. * except Exception as e:
  8555. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  8556. * sys.stderr.write("Naked Framework Error: Unable to read the file with UTF-8 encoding using the read_utf8() method (Naked.toolshed.file.py).")
  8557. * raise e
  8558. */
  8559. __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  8560. __Pyx_GOTREF(__pyx_t_10);
  8561. __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  8562. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  8563. if (__pyx_t_9) {
  8564. /* "lib/Naked/toolshed/c/file.pyx":370
  8565. * except Exception as e:
  8566. * if DEBUG_FLAG:
  8567. * sys.stderr.write("Naked Framework Error: Unable to read the file with UTF-8 encoding using the read_utf8() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  8568. * raise e
  8569. * finally:
  8570. */
  8571. __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  8572. __Pyx_GOTREF(__pyx_t_10);
  8573. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_stderr); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  8574. __Pyx_GOTREF(__pyx_t_4);
  8575. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  8576. __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_write); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  8577. __Pyx_GOTREF(__pyx_t_10);
  8578. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8579. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  8580. __Pyx_GOTREF(__pyx_t_4);
  8581. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  8582. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8583. goto __pyx_L27;
  8584. }
  8585. __pyx_L27:;
  8586. /* "lib/Naked/toolshed/c/file.pyx":371
  8587. * if DEBUG_FLAG:
  8588. * sys.stderr.write("Naked Framework Error: Unable to read the file with UTF-8 encoding using the read_utf8() method (Naked.toolshed.file.py).")
  8589. * raise e # <<<<<<<<<<<<<<
  8590. * finally:
  8591. * f.close()
  8592. */
  8593. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  8594. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L19_except_error;}
  8595. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  8596. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8597. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  8598. goto __pyx_L18_exception_handled;
  8599. }
  8600. goto __pyx_L19_except_error;
  8601. __pyx_L19_except_error:;
  8602. __Pyx_XGIVEREF(__pyx_t_3);
  8603. __Pyx_XGIVEREF(__pyx_t_2);
  8604. __Pyx_XGIVEREF(__pyx_t_1);
  8605. __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_2, __pyx_t_1);
  8606. goto __pyx_L15_error;
  8607. __pyx_L21_try_return:;
  8608. __Pyx_XGIVEREF(__pyx_t_3);
  8609. __Pyx_XGIVEREF(__pyx_t_2);
  8610. __Pyx_XGIVEREF(__pyx_t_1);
  8611. __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_2, __pyx_t_1);
  8612. goto __pyx_L14_return;
  8613. __pyx_L18_exception_handled:;
  8614. __Pyx_XGIVEREF(__pyx_t_3);
  8615. __Pyx_XGIVEREF(__pyx_t_2);
  8616. __Pyx_XGIVEREF(__pyx_t_1);
  8617. __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_2, __pyx_t_1);
  8618. __pyx_L24_try_end:;
  8619. }
  8620. }
  8621. /* "lib/Naked/toolshed/c/file.pyx":373
  8622. * raise e
  8623. * finally:
  8624. * f.close() # <<<<<<<<<<<<<<
  8625. *
  8626. *
  8627. */
  8628. /*finally:*/ {
  8629. /*exception exit:*/{
  8630. __pyx_L15_error:;
  8631. __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
  8632. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  8633. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  8634. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  8635. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  8636. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  8637. if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
  8638. if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3) < 0)) __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  8639. __Pyx_XGOTREF(__pyx_t_1);
  8640. __Pyx_XGOTREF(__pyx_t_2);
  8641. __Pyx_XGOTREF(__pyx_t_3);
  8642. __Pyx_XGOTREF(__pyx_t_13);
  8643. __Pyx_XGOTREF(__pyx_t_14);
  8644. __Pyx_XGOTREF(__pyx_t_15);
  8645. __pyx_t_8 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_12 = __pyx_filename;
  8646. {
  8647. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_close); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L29_error;}
  8648. __Pyx_GOTREF(__pyx_t_5);
  8649. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L29_error;}
  8650. __Pyx_GOTREF(__pyx_t_6);
  8651. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  8652. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8653. }
  8654. if (PY_MAJOR_VERSION >= 3) {
  8655. __Pyx_XGIVEREF(__pyx_t_13);
  8656. __Pyx_XGIVEREF(__pyx_t_14);
  8657. __Pyx_XGIVEREF(__pyx_t_15);
  8658. __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
  8659. }
  8660. __Pyx_XGIVEREF(__pyx_t_1);
  8661. __Pyx_XGIVEREF(__pyx_t_2);
  8662. __Pyx_XGIVEREF(__pyx_t_3);
  8663. __Pyx_ErrRestore(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  8664. __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
  8665. __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_12;
  8666. goto __pyx_L1_error;
  8667. __pyx_L29_error:;
  8668. if (PY_MAJOR_VERSION >= 3) {
  8669. __Pyx_XGIVEREF(__pyx_t_13);
  8670. __Pyx_XGIVEREF(__pyx_t_14);
  8671. __Pyx_XGIVEREF(__pyx_t_15);
  8672. __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
  8673. }
  8674. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  8675. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  8676. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  8677. __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0;
  8678. goto __pyx_L1_error;
  8679. }
  8680. __pyx_L14_return: {
  8681. __pyx_t_15 = __pyx_r;
  8682. __pyx_r = 0;
  8683. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_close); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8684. __Pyx_GOTREF(__pyx_t_6);
  8685. __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8686. __Pyx_GOTREF(__pyx_t_5);
  8687. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8688. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  8689. __pyx_r = __pyx_t_15;
  8690. __pyx_t_15 = 0;
  8691. goto __pyx_L0;
  8692. }
  8693. }
  8694. /* "lib/Naked/toolshed/c/file.pyx":355
  8695. * # test_file_read_utf8_missing_file
  8696. * #------------------------------------------------------------------------------
  8697. * def read_utf8(self): # <<<<<<<<<<<<<<
  8698. * try:
  8699. * import codecs
  8700. */
  8701. /* function exit code */
  8702. __pyx_L1_error:;
  8703. __Pyx_XDECREF(__pyx_t_4);
  8704. __Pyx_XDECREF(__pyx_t_5);
  8705. __Pyx_XDECREF(__pyx_t_6);
  8706. __Pyx_XDECREF(__pyx_t_7);
  8707. __Pyx_XDECREF(__pyx_t_10);
  8708. __Pyx_AddTraceback("lib.Naked.toolshed.c.file.FileReader.read_utf8", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8709. __pyx_r = NULL;
  8710. __pyx_L0:;
  8711. __Pyx_XDECREF(__pyx_v_codecs);
  8712. __Pyx_XDECREF(__pyx_v_f);
  8713. __Pyx_XDECREF(__pyx_v_ioe);
  8714. __Pyx_XDECREF(__pyx_v_textstring);
  8715. __Pyx_XDECREF(__pyx_v_unicodedata);
  8716. __Pyx_XDECREF(__pyx_v_norm_text);
  8717. __Pyx_XDECREF(__pyx_v_e);
  8718. __Pyx_XGIVEREF(__pyx_r);
  8719. __Pyx_RefNannyFinishContext();
  8720. return __pyx_r;
  8721. }
  8722. static PyMethodDef __pyx_methods[] = {
  8723. {0, 0, 0, 0}
  8724. };
  8725. #if PY_MAJOR_VERSION >= 3
  8726. static struct PyModuleDef __pyx_moduledef = {
  8727. #if PY_VERSION_HEX < 0x03020000
  8728. { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  8729. #else
  8730. PyModuleDef_HEAD_INIT,
  8731. #endif
  8732. __Pyx_NAMESTR("file"),
  8733. 0, /* m_doc */
  8734. -1, /* m_size */
  8735. __pyx_methods /* m_methods */,
  8736. NULL, /* m_reload */
  8737. NULL, /* m_traverse */
  8738. NULL, /* m_clear */
  8739. NULL /* m_free */
  8740. };
  8741. #endif
  8742. static __Pyx_StringTabEntry __pyx_string_tab[] = {
  8743. {&__pyx_n_s_DEBUG_FLAG, __pyx_k_DEBUG_FLAG, sizeof(__pyx_k_DEBUG_FLAG), 0, 0, 1, 1},
  8744. {&__pyx_n_s_Exception, __pyx_k_Exception, sizeof(__pyx_k_Exception), 0, 0, 1, 1},
  8745. {&__pyx_n_s_FileReader, __pyx_k_FileReader, sizeof(__pyx_k_FileReader), 0, 0, 1, 1},
  8746. {&__pyx_n_s_FileReader___init, __pyx_k_FileReader___init, sizeof(__pyx_k_FileReader___init), 0, 0, 1, 1},
  8747. {&__pyx_n_s_FileReader_read, __pyx_k_FileReader_read, sizeof(__pyx_k_FileReader_read), 0, 0, 1, 1},
  8748. {&__pyx_n_s_FileReader_read_as, __pyx_k_FileReader_read_as, sizeof(__pyx_k_FileReader_read_as), 0, 0, 1, 1},
  8749. {&__pyx_n_s_FileReader_read_bin, __pyx_k_FileReader_read_bin, sizeof(__pyx_k_FileReader_read_bin), 0, 0, 1, 1},
  8750. {&__pyx_n_s_FileReader_read_gzip, __pyx_k_FileReader_read_gzip, sizeof(__pyx_k_FileReader_read_gzip), 0, 0, 1, 1},
  8751. {&__pyx_n_s_FileReader_read_utf8, __pyx_k_FileReader_read_utf8, sizeof(__pyx_k_FileReader_read_utf8), 0, 0, 1, 1},
  8752. {&__pyx_n_s_FileReader_readlines, __pyx_k_FileReader_readlines, sizeof(__pyx_k_FileReader_readlines), 0, 0, 1, 1},
  8753. {&__pyx_n_s_FileReader_readlines_as, __pyx_k_FileReader_readlines_as, sizeof(__pyx_k_FileReader_readlines_as), 0, 0, 1, 1},
  8754. {&__pyx_n_s_FileReader_readlines_utf8, __pyx_k_FileReader_readlines_utf8, sizeof(__pyx_k_FileReader_readlines_utf8), 0, 0, 1, 1},
  8755. {&__pyx_n_s_FileWriter, __pyx_k_FileWriter, sizeof(__pyx_k_FileWriter), 0, 0, 1, 1},
  8756. {&__pyx_n_s_FileWriter___init, __pyx_k_FileWriter___init, sizeof(__pyx_k_FileWriter___init), 0, 0, 1, 1},
  8757. {&__pyx_n_s_FileWriter_append, __pyx_k_FileWriter_append, sizeof(__pyx_k_FileWriter_append), 0, 0, 1, 1},
  8758. {&__pyx_n_s_FileWriter_append_utf8, __pyx_k_FileWriter_append_utf8, sizeof(__pyx_k_FileWriter_append_utf8), 0, 0, 1, 1},
  8759. {&__pyx_n_s_FileWriter_gzip, __pyx_k_FileWriter_gzip, sizeof(__pyx_k_FileWriter_gzip), 0, 0, 1, 1},
  8760. {&__pyx_n_s_FileWriter_safe_write, __pyx_k_FileWriter_safe_write, sizeof(__pyx_k_FileWriter_safe_write), 0, 0, 1, 1},
  8761. {&__pyx_n_s_FileWriter_safe_write_bin, __pyx_k_FileWriter_safe_write_bin, sizeof(__pyx_k_FileWriter_safe_write_bin), 0, 0, 1, 1},
  8762. {&__pyx_n_s_FileWriter_write, __pyx_k_FileWriter_write, sizeof(__pyx_k_FileWriter_write), 0, 0, 1, 1},
  8763. {&__pyx_n_s_FileWriter_write_as, __pyx_k_FileWriter_write_as, sizeof(__pyx_k_FileWriter_write_as), 0, 0, 1, 1},
  8764. {&__pyx_n_s_FileWriter_write_bin, __pyx_k_FileWriter_write_bin, sizeof(__pyx_k_FileWriter_write_bin), 0, 0, 1, 1},
  8765. {&__pyx_n_s_FileWriter_write_utf8, __pyx_k_FileWriter_write_utf8, sizeof(__pyx_k_FileWriter_write_utf8), 0, 0, 1, 1},
  8766. {&__pyx_n_s_IO, __pyx_k_IO, sizeof(__pyx_k_IO), 0, 0, 1, 1},
  8767. {&__pyx_n_s_IOError, __pyx_k_IOError, sizeof(__pyx_k_IOError), 0, 0, 1, 1},
  8768. {&__pyx_n_s_IO___init, __pyx_k_IO___init, sizeof(__pyx_k_IO___init), 0, 0, 1, 1},
  8769. {&__pyx_n_s_NFKD, __pyx_k_NFKD, sizeof(__pyx_k_NFKD), 0, 0, 1, 1},
  8770. {&__pyx_kp_s_Naked_Framework_Error_Unable_to, __pyx_k_Naked_Framework_Error_Unable_to, sizeof(__pyx_k_Naked_Framework_Error_Unable_to), 0, 0, 1, 0},
  8771. {&__pyx_kp_s_Naked_Framework_Error_Unable_to_10, __pyx_k_Naked_Framework_Error_Unable_to_10, sizeof(__pyx_k_Naked_Framework_Error_Unable_to_10), 0, 0, 1, 0},
  8772. {&__pyx_kp_s_Naked_Framework_Error_Unable_to_11, __pyx_k_Naked_Framework_Error_Unable_to_11, sizeof(__pyx_k_Naked_Framework_Error_Unable_to_11), 0, 0, 1, 0},
  8773. {&__pyx_kp_s_Naked_Framework_Error_Unable_to_12, __pyx_k_Naked_Framework_Error_Unable_to_12, sizeof(__pyx_k_Naked_Framework_Error_Unable_to_12), 0, 0, 1, 0},
  8774. {&__pyx_kp_s_Naked_Framework_Error_Unable_to_13, __pyx_k_Naked_Framework_Error_Unable_to_13, sizeof(__pyx_k_Naked_Framework_Error_Unable_to_13), 0, 0, 1, 0},
  8775. {&__pyx_kp_s_Naked_Framework_Error_Unable_to_14, __pyx_k_Naked_Framework_Error_Unable_to_14, sizeof(__pyx_k_Naked_Framework_Error_Unable_to_14), 0, 0, 1, 0},
  8776. {&__pyx_kp_s_Naked_Framework_Error_Unable_to_15, __pyx_k_Naked_Framework_Error_Unable_to_15, sizeof(__pyx_k_Naked_Framework_Error_Unable_to_15), 0, 0, 1, 0},
  8777. {&__pyx_kp_s_Naked_Framework_Error_Unable_to_2, __pyx_k_Naked_Framework_Error_Unable_to_2, sizeof(__pyx_k_Naked_Framework_Error_Unable_to_2), 0, 0, 1, 0},
  8778. {&__pyx_kp_s_Naked_Framework_Error_Unable_to_3, __pyx_k_Naked_Framework_Error_Unable_to_3, sizeof(__pyx_k_Naked_Framework_Error_Unable_to_3), 0, 0, 1, 0},
  8779. {&__pyx_kp_s_Naked_Framework_Error_Unable_to_4, __pyx_k_Naked_Framework_Error_Unable_to_4, sizeof(__pyx_k_Naked_Framework_Error_Unable_to_4), 0, 0, 1, 0},
  8780. {&__pyx_kp_s_Naked_Framework_Error_Unable_to_5, __pyx_k_Naked_Framework_Error_Unable_to_5, sizeof(__pyx_k_Naked_Framework_Error_Unable_to_5), 0, 0, 1, 0},
  8781. {&__pyx_kp_s_Naked_Framework_Error_Unable_to_6, __pyx_k_Naked_Framework_Error_Unable_to_6, sizeof(__pyx_k_Naked_Framework_Error_Unable_to_6), 0, 0, 1, 0},
  8782. {&__pyx_kp_s_Naked_Framework_Error_Unable_to_7, __pyx_k_Naked_Framework_Error_Unable_to_7, sizeof(__pyx_k_Naked_Framework_Error_Unable_to_7), 0, 0, 1, 0},
  8783. {&__pyx_kp_s_Naked_Framework_Error_Unable_to_8, __pyx_k_Naked_Framework_Error_Unable_to_8, sizeof(__pyx_k_Naked_Framework_Error_Unable_to_8), 0, 0, 1, 0},
  8784. {&__pyx_kp_s_Naked_Framework_Error_Unable_to_9, __pyx_k_Naked_Framework_Error_Unable_to_9, sizeof(__pyx_k_Naked_Framework_Error_Unable_to_9), 0, 0, 1, 0},
  8785. {&__pyx_kp_s_Naked_Framework_Error_unable_to, __pyx_k_Naked_Framework_Error_unable_to, sizeof(__pyx_k_Naked_Framework_Error_unable_to), 0, 0, 1, 0},
  8786. {&__pyx_kp_s_Naked_Framework_Error_unable_to_2, __pyx_k_Naked_Framework_Error_unable_to_2, sizeof(__pyx_k_Naked_Framework_Error_unable_to_2), 0, 0, 1, 0},
  8787. {&__pyx_kp_s_Naked_Framework_Error_unable_to_3, __pyx_k_Naked_Framework_Error_unable_to_3, sizeof(__pyx_k_Naked_Framework_Error_unable_to_3), 0, 0, 1, 0},
  8788. {&__pyx_kp_s_Naked_Framework_Error_unable_to_4, __pyx_k_Naked_Framework_Error_unable_to_4, sizeof(__pyx_k_Naked_Framework_Error_unable_to_4), 0, 0, 1, 0},
  8789. {&__pyx_n_s_Naked_settings, __pyx_k_Naked_settings, sizeof(__pyx_k_Naked_settings), 0, 0, 1, 1},
  8790. {&__pyx_n_s_Naked_toolshed_system, __pyx_k_Naked_toolshed_system, sizeof(__pyx_k_Naked_toolshed_system), 0, 0, 1, 1},
  8791. {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  8792. {&__pyx_kp_s_The_file_specified_for_the_text, __pyx_k_The_file_specified_for_the_text, sizeof(__pyx_k_The_file_specified_for_the_text), 0, 0, 1, 0},
  8793. {&__pyx_kp_s_The_file_specified_for_the_text_2, __pyx_k_The_file_specified_for_the_text_2, sizeof(__pyx_k_The_file_specified_for_the_text_2), 0, 0, 1, 0},
  8794. {&__pyx_kp_s_The_text_encoding_was_not_specif, __pyx_k_The_text_encoding_was_not_specif, sizeof(__pyx_k_The_text_encoding_was_not_specif), 0, 0, 1, 0},
  8795. {&__pyx_kp_s_The_text_file_encoding_was_not_s, __pyx_k_The_text_file_encoding_was_not_s, sizeof(__pyx_k_The_text_file_encoding_was_not_s), 0, 0, 1, 0},
  8796. {&__pyx_kp_s_The_text_file_encoding_was_not_s_2, __pyx_k_The_text_file_encoding_was_not_s_2, sizeof(__pyx_k_The_text_file_encoding_was_not_s_2), 0, 0, 1, 0},
  8797. {&__pyx_n_s_UTF8, __pyx_k_UTF8, sizeof(__pyx_k_UTF8), 0, 0, 1, 1},
  8798. {&__pyx_kp_s_UTF_8, __pyx_k_UTF_8, sizeof(__pyx_k_UTF_8), 0, 0, 1, 0},
  8799. {&__pyx_n_s_UTF_8_2, __pyx_k_UTF_8_2, sizeof(__pyx_k_UTF_8_2), 0, 0, 1, 1},
  8800. {&__pyx_n_s_UnicodeEncodeError, __pyx_k_UnicodeEncodeError, sizeof(__pyx_k_UnicodeEncodeError), 0, 0, 1, 1},
  8801. {&__pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_k_Users_ces_Desktop_code_naked_li, sizeof(__pyx_k_Users_ces_Desktop_code_naked_li), 0, 0, 1, 0},
  8802. {&__pyx_kp_s__13, __pyx_k__13, sizeof(__pyx_k__13), 0, 0, 1, 0},
  8803. {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1},
  8804. {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
  8805. {&__pyx_n_s_append_utf8, __pyx_k_append_utf8, sizeof(__pyx_k_append_utf8), 0, 0, 1, 1},
  8806. {&__pyx_n_s_appender, __pyx_k_appender, sizeof(__pyx_k_appender), 0, 0, 1, 1},
  8807. {&__pyx_n_s_bin_reader, __pyx_k_bin_reader, sizeof(__pyx_k_bin_reader), 0, 0, 1, 1},
  8808. {&__pyx_n_s_bin_writer, __pyx_k_bin_writer, sizeof(__pyx_k_bin_writer), 0, 0, 1, 1},
  8809. {&__pyx_n_s_binary_data, __pyx_k_binary_data, sizeof(__pyx_k_binary_data), 0, 0, 1, 1},
  8810. {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  8811. {&__pyx_n_s_codecs, __pyx_k_codecs, sizeof(__pyx_k_codecs), 0, 0, 1, 1},
  8812. {&__pyx_n_s_compression_level, __pyx_k_compression_level, sizeof(__pyx_k_compression_level), 0, 0, 1, 1},
  8813. {&__pyx_n_s_compresslevel, __pyx_k_compresslevel, sizeof(__pyx_k_compresslevel), 0, 0, 1, 1},
  8814. {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
  8815. {&__pyx_n_s_data_list, __pyx_k_data_list, sizeof(__pyx_k_data_list), 0, 0, 1, 1},
  8816. {&__pyx_n_s_debug, __pyx_k_debug, sizeof(__pyx_k_debug), 0, 0, 1, 1},
  8817. {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 0, 0, 1, 1},
  8818. {&__pyx_n_s_dev_spec_encoding, __pyx_k_dev_spec_encoding, sizeof(__pyx_k_dev_spec_encoding), 0, 0, 1, 1},
  8819. {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  8820. {&__pyx_n_s_e, __pyx_k_e, sizeof(__pyx_k_e), 0, 0, 1, 1},
  8821. {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
  8822. {&__pyx_n_s_encoding, __pyx_k_encoding, sizeof(__pyx_k_encoding), 0, 0, 1, 1},
  8823. {&__pyx_n_s_endswith, __pyx_k_endswith, sizeof(__pyx_k_endswith), 0, 0, 1, 1},
  8824. {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1},
  8825. {&__pyx_n_s_exists, __pyx_k_exists, sizeof(__pyx_k_exists), 0, 0, 1, 1},
  8826. {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
  8827. {&__pyx_n_s_f, __pyx_k_f, sizeof(__pyx_k_f), 0, 0, 1, 1},
  8828. {&__pyx_n_s_file_data, __pyx_k_file_data, sizeof(__pyx_k_file_data), 0, 0, 1, 1},
  8829. {&__pyx_n_s_file_exists, __pyx_k_file_exists, sizeof(__pyx_k_file_exists), 0, 0, 1, 1},
  8830. {&__pyx_n_s_filepath, __pyx_k_filepath, sizeof(__pyx_k_filepath), 0, 0, 1, 1},
  8831. {&__pyx_kp_s_gz, __pyx_k_gz, sizeof(__pyx_k_gz), 0, 0, 1, 0},
  8832. {&__pyx_n_s_gzip, __pyx_k_gzip, sizeof(__pyx_k_gzip), 0, 0, 1, 1},
  8833. {&__pyx_n_s_gzip_reader, __pyx_k_gzip_reader, sizeof(__pyx_k_gzip_reader), 0, 0, 1, 1},
  8834. {&__pyx_n_s_gzip_writer, __pyx_k_gzip_writer, sizeof(__pyx_k_gzip_writer), 0, 0, 1, 1},
  8835. {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  8836. {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
  8837. {&__pyx_n_s_ioe, __pyx_k_ioe, sizeof(__pyx_k_ioe), 0, 0, 1, 1},
  8838. {&__pyx_n_s_lib_Naked_toolshed_c_file, __pyx_k_lib_Naked_toolshed_c_file, sizeof(__pyx_k_lib_Naked_toolshed_c_file), 0, 0, 1, 1},
  8839. {&__pyx_n_s_line, __pyx_k_line, sizeof(__pyx_k_line), 0, 0, 1, 1},
  8840. {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  8841. {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
  8842. {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
  8843. {&__pyx_n_s_modified_text_list, __pyx_k_modified_text_list, sizeof(__pyx_k_modified_text_list), 0, 0, 1, 1},
  8844. {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  8845. {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  8846. {&__pyx_n_s_norm_data, __pyx_k_norm_data, sizeof(__pyx_k_norm_data), 0, 0, 1, 1},
  8847. {&__pyx_n_s_norm_line, __pyx_k_norm_line, sizeof(__pyx_k_norm_line), 0, 0, 1, 1},
  8848. {&__pyx_n_s_norm_text, __pyx_k_norm_text, sizeof(__pyx_k_norm_text), 0, 0, 1, 1},
  8849. {&__pyx_n_s_normalize, __pyx_k_normalize, sizeof(__pyx_k_normalize), 0, 0, 1, 1},
  8850. {&__pyx_n_s_open, __pyx_k_open, sizeof(__pyx_k_open), 0, 0, 1, 1},
  8851. {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1},
  8852. {&__pyx_n_s_os_path, __pyx_k_os_path, sizeof(__pyx_k_os_path), 0, 0, 1, 1},
  8853. {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1},
  8854. {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  8855. {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  8856. {&__pyx_n_s_r, __pyx_k_r, sizeof(__pyx_k_r), 0, 0, 1, 1},
  8857. {&__pyx_n_s_rb, __pyx_k_rb, sizeof(__pyx_k_rb), 0, 0, 1, 1},
  8858. {&__pyx_n_s_read, __pyx_k_read, sizeof(__pyx_k_read), 0, 0, 1, 1},
  8859. {&__pyx_n_s_read_as, __pyx_k_read_as, sizeof(__pyx_k_read_as), 0, 0, 1, 1},
  8860. {&__pyx_n_s_read_bin, __pyx_k_read_bin, sizeof(__pyx_k_read_bin), 0, 0, 1, 1},
  8861. {&__pyx_n_s_read_gzip, __pyx_k_read_gzip, sizeof(__pyx_k_read_gzip), 0, 0, 1, 1},
  8862. {&__pyx_n_s_read_utf8, __pyx_k_read_utf8, sizeof(__pyx_k_read_utf8), 0, 0, 1, 1},
  8863. {&__pyx_n_s_reader, __pyx_k_reader, sizeof(__pyx_k_reader), 0, 0, 1, 1},
  8864. {&__pyx_n_s_readlines, __pyx_k_readlines, sizeof(__pyx_k_readlines), 0, 0, 1, 1},
  8865. {&__pyx_n_s_readlines_as, __pyx_k_readlines_as, sizeof(__pyx_k_readlines_as), 0, 0, 1, 1},
  8866. {&__pyx_n_s_readlines_utf8, __pyx_k_readlines_utf8, sizeof(__pyx_k_readlines_utf8), 0, 0, 1, 1},
  8867. {&__pyx_n_s_safe_write, __pyx_k_safe_write, sizeof(__pyx_k_safe_write), 0, 0, 1, 1},
  8868. {&__pyx_n_s_safe_write_bin, __pyx_k_safe_write_bin, sizeof(__pyx_k_safe_write_bin), 0, 0, 1, 1},
  8869. {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
  8870. {&__pyx_n_s_stderr, __pyx_k_stderr, sizeof(__pyx_k_stderr), 0, 0, 1, 1},
  8871. {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
  8872. {&__pyx_n_s_system_default, __pyx_k_system_default, sizeof(__pyx_k_system_default), 0, 0, 1, 1},
  8873. {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  8874. {&__pyx_n_s_text, __pyx_k_text, sizeof(__pyx_k_text), 0, 0, 1, 1},
  8875. {&__pyx_n_s_textstring, __pyx_k_textstring, sizeof(__pyx_k_textstring), 0, 0, 1, 1},
  8876. {&__pyx_n_s_the_encoding, __pyx_k_the_encoding, sizeof(__pyx_k_the_encoding), 0, 0, 1, 1},
  8877. {&__pyx_n_s_ue, __pyx_k_ue, sizeof(__pyx_k_ue), 0, 0, 1, 1},
  8878. {&__pyx_n_s_uni_reader, __pyx_k_uni_reader, sizeof(__pyx_k_uni_reader), 0, 0, 1, 1},
  8879. {&__pyx_n_s_unicodedata, __pyx_k_unicodedata, sizeof(__pyx_k_unicodedata), 0, 0, 1, 1},
  8880. {&__pyx_n_s_utf8, __pyx_k_utf8, sizeof(__pyx_k_utf8), 0, 0, 1, 1},
  8881. {&__pyx_n_s_utf_8, __pyx_k_utf_8, sizeof(__pyx_k_utf_8), 0, 0, 1, 1},
  8882. {&__pyx_kp_s_utf_8_2, __pyx_k_utf_8_2, sizeof(__pyx_k_utf_8_2), 0, 0, 1, 0},
  8883. {&__pyx_n_s_w, __pyx_k_w, sizeof(__pyx_k_w), 0, 0, 1, 1},
  8884. {&__pyx_n_s_wb, __pyx_k_wb, sizeof(__pyx_k_wb), 0, 0, 1, 1},
  8885. {&__pyx_n_s_write, __pyx_k_write, sizeof(__pyx_k_write), 0, 0, 1, 1},
  8886. {&__pyx_n_s_write_as, __pyx_k_write_as, sizeof(__pyx_k_write_as), 0, 0, 1, 1},
  8887. {&__pyx_n_s_write_bin, __pyx_k_write_bin, sizeof(__pyx_k_write_bin), 0, 0, 1, 1},
  8888. {&__pyx_n_s_write_utf8, __pyx_k_write_utf8, sizeof(__pyx_k_write_utf8), 0, 0, 1, 1},
  8889. {&__pyx_n_s_writer, __pyx_k_writer, sizeof(__pyx_k_writer), 0, 0, 1, 1},
  8890. {&__pyx_n_s_wt, __pyx_k_wt, sizeof(__pyx_k_wt), 0, 0, 1, 1},
  8891. {0, 0, 0, 0, 0, 0, 0}
  8892. };
  8893. static int __Pyx_InitCachedBuiltins(void) {
  8894. __pyx_builtin_IOError = __Pyx_GetBuiltinName(__pyx_n_s_IOError); if (!__pyx_builtin_IOError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8895. __pyx_builtin_open = __Pyx_GetBuiltinName(__pyx_n_s_open); if (!__pyx_builtin_open) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8896. __pyx_builtin_UnicodeEncodeError = __Pyx_GetBuiltinName(__pyx_n_s_UnicodeEncodeError); if (!__pyx_builtin_UnicodeEncodeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8897. __pyx_builtin_Exception = __Pyx_GetBuiltinName(__pyx_n_s_Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8898. __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8899. return 0;
  8900. __pyx_L1_error:;
  8901. return -1;
  8902. }
  8903. static int __Pyx_InitCachedConstants(void) {
  8904. __Pyx_RefNannyDeclarations
  8905. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  8906. /* "lib/Naked/toolshed/c/file.pyx":33
  8907. * from Naked.toolshed.system import file_exists
  8908. * if not file_exists(self.filepath): #confirm that file exists, if not raise IOError (assuming that developer expected existing file if using append)
  8909. * raise IOError("The file specified for the text append does not exist (Naked.toolshed.file.py:append).") # <<<<<<<<<<<<<<
  8910. * with open(self.filepath, 'a') as appender:
  8911. * appender.write(text)
  8912. */
  8913. __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_The_file_specified_for_the_text); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8914. __Pyx_GOTREF(__pyx_tuple_);
  8915. __Pyx_GIVEREF(__pyx_tuple_);
  8916. /* "lib/Naked/toolshed/c/file.pyx":34
  8917. * if not file_exists(self.filepath): #confirm that file exists, if not raise IOError (assuming that developer expected existing file if using append)
  8918. * raise IOError("The file specified for the text append does not exist (Naked.toolshed.file.py:append).")
  8919. * with open(self.filepath, 'a') as appender: # <<<<<<<<<<<<<<
  8920. * appender.write(text)
  8921. * except UnicodeEncodeError as ue:
  8922. */
  8923. __pyx_tuple__2 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8924. __Pyx_GOTREF(__pyx_tuple__2);
  8925. __Pyx_GIVEREF(__pyx_tuple__2);
  8926. /* "lib/Naked/toolshed/c/file.pyx":40
  8927. * except Exception as e:
  8928. * if DEBUG_FLAG:
  8929. * sys.stderr.write("Naked Framework Error: Unable to append text to the file with the append() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  8930. * raise e
  8931. *
  8932. */
  8933. __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_Naked_Framework_Error_Unable_to); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8934. __Pyx_GOTREF(__pyx_tuple__3);
  8935. __Pyx_GIVEREF(__pyx_tuple__3);
  8936. /* "lib/Naked/toolshed/c/file.pyx":52
  8937. * from Naked.toolshed.system import file_exists
  8938. * if not file_exists(self.filepath):
  8939. * raise IOError("The file specified for the text append does not exist (Naked.toolshed.file.py:append_utf8).") # <<<<<<<<<<<<<<
  8940. * import codecs
  8941. * import unicodedata
  8942. */
  8943. __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_The_file_specified_for_the_text_2); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8944. __Pyx_GOTREF(__pyx_tuple__4);
  8945. __Pyx_GIVEREF(__pyx_tuple__4);
  8946. /* "lib/Naked/toolshed/c/file.pyx":56
  8947. * import unicodedata
  8948. * norm_text = unicodedata.normalize('NFKD', text) # NKFD normalization of the unicode data before write
  8949. * with codecs.open(self.filepath, mode='a', encoding="utf_8") as appender: # <<<<<<<<<<<<<<
  8950. * appender.write(norm_text)
  8951. * except Exception as e:
  8952. */
  8953. __pyx_tuple__5 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8954. __Pyx_GOTREF(__pyx_tuple__5);
  8955. __Pyx_GIVEREF(__pyx_tuple__5);
  8956. /* "lib/Naked/toolshed/c/file.pyx":60
  8957. * except Exception as e:
  8958. * if DEBUG_FLAG:
  8959. * sys.stderr.write("Naked Framework Error: Unable to append text to the file with the append_utf8 method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  8960. * raise e
  8961. *
  8962. */
  8963. __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_Naked_Framework_Error_Unable_to_2); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8964. __Pyx_GOTREF(__pyx_tuple__6);
  8965. __Pyx_GIVEREF(__pyx_tuple__6);
  8966. /* "lib/Naked/toolshed/c/file.pyx":74
  8967. * try:
  8968. * import gzip
  8969. * if not self.filepath.endswith(".gz"): # <<<<<<<<<<<<<<
  8970. * self.filepath = self.filepath + ".gz"
  8971. * with gzip.open(self.filepath, 'wb', compresslevel=compression_level) as gzip_writer:
  8972. */
  8973. __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_gz); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8974. __Pyx_GOTREF(__pyx_tuple__7);
  8975. __Pyx_GIVEREF(__pyx_tuple__7);
  8976. /* "lib/Naked/toolshed/c/file.pyx":76
  8977. * if not self.filepath.endswith(".gz"):
  8978. * self.filepath = self.filepath + ".gz"
  8979. * with gzip.open(self.filepath, 'wb', compresslevel=compression_level) as gzip_writer: # <<<<<<<<<<<<<<
  8980. * gzip_writer.write(text)
  8981. * except UnicodeEncodeError as ue:
  8982. */
  8983. __pyx_tuple__8 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8984. __Pyx_GOTREF(__pyx_tuple__8);
  8985. __Pyx_GIVEREF(__pyx_tuple__8);
  8986. /* "lib/Naked/toolshed/c/file.pyx":83
  8987. * import codecs
  8988. * binary_data = codecs.encode(norm_text, "utf_8")
  8989. * with gzip.open(self.filepath, 'wb', compresslevel=compression_level) as gzip_writer: # <<<<<<<<<<<<<<
  8990. * gzip_writer.write(binary_data)
  8991. * except Exception as e:
  8992. */
  8993. __pyx_tuple__9 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8994. __Pyx_GOTREF(__pyx_tuple__9);
  8995. __Pyx_GIVEREF(__pyx_tuple__9);
  8996. /* "lib/Naked/toolshed/c/file.pyx":87
  8997. * except Exception as e:
  8998. * if DEBUG_FLAG:
  8999. * sys.stderr.write("Naked Framework Error: unable to gzip compress the file with the gzip method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  9000. * raise e
  9001. *
  9002. */
  9003. __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_Naked_Framework_Error_unable_to); if (unlikely(!__pyx_tuple__10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9004. __Pyx_GOTREF(__pyx_tuple__10);
  9005. __Pyx_GIVEREF(__pyx_tuple__10);
  9006. /* "lib/Naked/toolshed/c/file.pyx":98
  9007. * def write(self, text):
  9008. * try:
  9009. * with open(self.filepath, 'wt') as writer: # <<<<<<<<<<<<<<
  9010. * writer.write(text)
  9011. * except UnicodeEncodeError as ue:
  9012. */
  9013. __pyx_tuple__11 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9014. __Pyx_GOTREF(__pyx_tuple__11);
  9015. __Pyx_GIVEREF(__pyx_tuple__11);
  9016. /* "lib/Naked/toolshed/c/file.pyx":104
  9017. * except Exception as e:
  9018. * if DEBUG_FLAG:
  9019. * sys.stderr.write("Naked Framework Error: Unable to write to requested file with the write() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  9020. * raise e
  9021. *
  9022. */
  9023. __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_Naked_Framework_Error_Unable_to_3); if (unlikely(!__pyx_tuple__12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9024. __Pyx_GOTREF(__pyx_tuple__12);
  9025. __Pyx_GIVEREF(__pyx_tuple__12);
  9026. /* "lib/Naked/toolshed/c/file.pyx":115
  9027. * try:
  9028. * if the_encoding == "": #if the developer did not include the encoding type, raise an exception
  9029. * raise RuntimeError("The text encoding was not specified as an argument to the write_as() method (Naked.toolshed.file.py:write_as).") # <<<<<<<<<<<<<<
  9030. * import codecs
  9031. * with codecs.open(self.filepath, encoding=the_encoding, mode='w') as f:
  9032. */
  9033. __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_The_text_encoding_was_not_specif); if (unlikely(!__pyx_tuple__14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9034. __Pyx_GOTREF(__pyx_tuple__14);
  9035. __Pyx_GIVEREF(__pyx_tuple__14);
  9036. /* "lib/Naked/toolshed/c/file.pyx":117
  9037. * raise RuntimeError("The text encoding was not specified as an argument to the write_as() method (Naked.toolshed.file.py:write_as).")
  9038. * import codecs
  9039. * with codecs.open(self.filepath, encoding=the_encoding, mode='w') as f: # <<<<<<<<<<<<<<
  9040. * f.write(text)
  9041. * except Exception as e:
  9042. */
  9043. __pyx_tuple__15 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9044. __Pyx_GOTREF(__pyx_tuple__15);
  9045. __Pyx_GIVEREF(__pyx_tuple__15);
  9046. /* "lib/Naked/toolshed/c/file.pyx":121
  9047. * except Exception as e:
  9048. * if DEBUG_FLAG:
  9049. * sys.stderr.write("Naked Framework Error: unable to write file with the specified encoding using the write_as() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  9050. * raise e
  9051. *
  9052. */
  9053. __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_Naked_Framework_Error_unable_to_2); if (unlikely(!__pyx_tuple__16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9054. __Pyx_GOTREF(__pyx_tuple__16);
  9055. __Pyx_GIVEREF(__pyx_tuple__16);
  9056. /* "lib/Naked/toolshed/c/file.pyx":131
  9057. * def write_bin(self, binary_data):
  9058. * try:
  9059. * with open(self.filepath, 'wb') as bin_writer: # <<<<<<<<<<<<<<
  9060. * bin_writer.write(binary_data)
  9061. * except Exception as e:
  9062. */
  9063. __pyx_tuple__17 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9064. __Pyx_GOTREF(__pyx_tuple__17);
  9065. __Pyx_GIVEREF(__pyx_tuple__17);
  9066. /* "lib/Naked/toolshed/c/file.pyx":135
  9067. * except Exception as e:
  9068. * if DEBUG_FLAG:
  9069. * sys.stderr.write("Naked Framework Error: Unable to write binary data to file with the write_bin method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  9070. * raise e
  9071. *
  9072. */
  9073. __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_Naked_Framework_Error_Unable_to_4); if (unlikely(!__pyx_tuple__18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9074. __Pyx_GOTREF(__pyx_tuple__18);
  9075. __Pyx_GIVEREF(__pyx_tuple__18);
  9076. /* "lib/Naked/toolshed/c/file.pyx":148
  9077. * if not os.path.exists(self.filepath): # if the file does not exist, then can write
  9078. * try:
  9079. * with open(self.filepath, 'wt') as writer: # <<<<<<<<<<<<<<
  9080. * writer.write(text)
  9081. * return True
  9082. */
  9083. __pyx_tuple__19 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9084. __Pyx_GOTREF(__pyx_tuple__19);
  9085. __Pyx_GIVEREF(__pyx_tuple__19);
  9086. /* "lib/Naked/toolshed/c/file.pyx":156
  9087. * except Exception as e:
  9088. * if DEBUG_FLAG:
  9089. * sys.stderr.write("Naked Framework Error: Unable to write to requested file with the safe_write() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  9090. * raise e
  9091. * else:
  9092. */
  9093. __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_Naked_Framework_Error_Unable_to_5); if (unlikely(!__pyx_tuple__20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9094. __Pyx_GOTREF(__pyx_tuple__20);
  9095. __Pyx_GIVEREF(__pyx_tuple__20);
  9096. /* "lib/Naked/toolshed/c/file.pyx":170
  9097. * import os.path
  9098. * if not os.path.exists(self.filepath):
  9099. * with open(self.filepath, 'wb') as writer: # <<<<<<<<<<<<<<
  9100. * writer.write(file_data)
  9101. * return True
  9102. */
  9103. __pyx_tuple__21 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9104. __Pyx_GOTREF(__pyx_tuple__21);
  9105. __Pyx_GIVEREF(__pyx_tuple__21);
  9106. /* "lib/Naked/toolshed/c/file.pyx":177
  9107. * except Exception as e:
  9108. * if DEBUG_FLAG:
  9109. * sys.stderr.write("Naked Framework Error: Unable to write to requested file with the safe_write_bin() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  9110. * raise e
  9111. *
  9112. */
  9113. __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_Naked_Framework_Error_Unable_to_6); if (unlikely(!__pyx_tuple__22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9114. __Pyx_GOTREF(__pyx_tuple__22);
  9115. __Pyx_GIVEREF(__pyx_tuple__22);
  9116. /* "lib/Naked/toolshed/c/file.pyx":194
  9117. * except IOError as ioe:
  9118. * if DEBUG_FLAG:
  9119. * sys.stderr.write("Naked Framework Error: Unable to open file for write with the write_utf8() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  9120. * raise ioe
  9121. * try:
  9122. */
  9123. __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_Naked_Framework_Error_Unable_to_7); if (unlikely(!__pyx_tuple__23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9124. __Pyx_GOTREF(__pyx_tuple__23);
  9125. __Pyx_GIVEREF(__pyx_tuple__23);
  9126. /* "lib/Naked/toolshed/c/file.pyx":202
  9127. * except Exception as e:
  9128. * if DEBUG_FLAG:
  9129. * sys.stderr.write("Naked Framework Error: Unable to write UTF-8 encoded text to file with the write_utf8() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  9130. * raise e
  9131. * finally:
  9132. */
  9133. __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_Naked_Framework_Error_Unable_to_8); if (unlikely(!__pyx_tuple__24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9134. __Pyx_GOTREF(__pyx_tuple__24);
  9135. __Pyx_GIVEREF(__pyx_tuple__24);
  9136. /* "lib/Naked/toolshed/c/file.pyx":227
  9137. * except Exception as e:
  9138. * if DEBUG_FLAG:
  9139. * sys.stderr.write("Naked Framework Error: Unable to read text from the requested file with the read() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  9140. * raise e
  9141. *
  9142. */
  9143. __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_Naked_Framework_Error_Unable_to_9); if (unlikely(!__pyx_tuple__25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9144. __Pyx_GOTREF(__pyx_tuple__25);
  9145. __Pyx_GIVEREF(__pyx_tuple__25);
  9146. /* "lib/Naked/toolshed/c/file.pyx":238
  9147. * def read_bin(self):
  9148. * try:
  9149. * with open(self.filepath, 'rb') as bin_reader: # <<<<<<<<<<<<<<
  9150. * data = bin_reader.read()
  9151. * return data
  9152. */
  9153. __pyx_tuple__26 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9154. __Pyx_GOTREF(__pyx_tuple__26);
  9155. __Pyx_GIVEREF(__pyx_tuple__26);
  9156. __pyx_tuple__27 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9157. __Pyx_GOTREF(__pyx_tuple__27);
  9158. __Pyx_GIVEREF(__pyx_tuple__27);
  9159. /* "lib/Naked/toolshed/c/file.pyx":243
  9160. * except Exception as e:
  9161. * if DEBUG_FLAG:
  9162. * sys.stderr.write("Naked Framework Error: Unable to read the binary data from the file with the read_bin method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  9163. * raise e
  9164. *
  9165. */
  9166. __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_Naked_Framework_Error_Unable_to_10); if (unlikely(!__pyx_tuple__28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9167. __Pyx_GOTREF(__pyx_tuple__28);
  9168. __Pyx_GIVEREF(__pyx_tuple__28);
  9169. /* "lib/Naked/toolshed/c/file.pyx":255
  9170. * try:
  9171. * if the_encoding == "":
  9172. * raise RuntimeError("The text file encoding was not specified as an argument to the read_as method (Naked.toolshed.file.py:read_as).") # <<<<<<<<<<<<<<
  9173. * import codecs
  9174. * with codecs.open(self.filepath, encoding=the_encoding, mode='r') as f:
  9175. */
  9176. __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_The_text_file_encoding_was_not_s); if (unlikely(!__pyx_tuple__29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9177. __Pyx_GOTREF(__pyx_tuple__29);
  9178. __Pyx_GIVEREF(__pyx_tuple__29);
  9179. /* "lib/Naked/toolshed/c/file.pyx":257
  9180. * raise RuntimeError("The text file encoding was not specified as an argument to the read_as method (Naked.toolshed.file.py:read_as).")
  9181. * import codecs
  9182. * with codecs.open(self.filepath, encoding=the_encoding, mode='r') as f: # <<<<<<<<<<<<<<
  9183. * data = f.read()
  9184. * return data
  9185. */
  9186. __pyx_tuple__30 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9187. __Pyx_GOTREF(__pyx_tuple__30);
  9188. __Pyx_GIVEREF(__pyx_tuple__30);
  9189. /* "lib/Naked/toolshed/c/file.pyx":262
  9190. * except Exception as e:
  9191. * if DEBUG_FLAG:
  9192. * sys.stderr.write("Naked Framework Error: Unable to read the file with the developer specified text encoding with the read_as method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  9193. * raise e
  9194. *
  9195. */
  9196. __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_Naked_Framework_Error_Unable_to_11); if (unlikely(!__pyx_tuple__31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9197. __Pyx_GOTREF(__pyx_tuple__31);
  9198. __Pyx_GIVEREF(__pyx_tuple__31);
  9199. /* "lib/Naked/toolshed/c/file.pyx":276
  9200. * except Exception as e:
  9201. * if DEBUG_FLAG:
  9202. * sys.stderr.write("Naked Framework Error: Unable to read text from the requested file with the readlines() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  9203. * raise e
  9204. *
  9205. */
  9206. __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_Naked_Framework_Error_Unable_to_12); if (unlikely(!__pyx_tuple__32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9207. __Pyx_GOTREF(__pyx_tuple__32);
  9208. __Pyx_GIVEREF(__pyx_tuple__32);
  9209. /* "lib/Naked/toolshed/c/file.pyx":288
  9210. * try:
  9211. * if dev_spec_encoding == "":
  9212. * raise RuntimeError("The text file encoding was not specified as an argument to the readlines_as method (Naked.toolshed.file.py:readlines_as).") # <<<<<<<<<<<<<<
  9213. * import codecs
  9214. * with codecs.open(self.filepath, encoding=dev_spec_encoding, mode='r') as reader:
  9215. */
  9216. __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_The_text_file_encoding_was_not_s_2); if (unlikely(!__pyx_tuple__33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9217. __Pyx_GOTREF(__pyx_tuple__33);
  9218. __Pyx_GIVEREF(__pyx_tuple__33);
  9219. /* "lib/Naked/toolshed/c/file.pyx":290
  9220. * raise RuntimeError("The text file encoding was not specified as an argument to the readlines_as method (Naked.toolshed.file.py:readlines_as).")
  9221. * import codecs
  9222. * with codecs.open(self.filepath, encoding=dev_spec_encoding, mode='r') as reader: # <<<<<<<<<<<<<<
  9223. * data_list = []
  9224. * for line in reader:
  9225. */
  9226. __pyx_tuple__34 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9227. __Pyx_GOTREF(__pyx_tuple__34);
  9228. __Pyx_GIVEREF(__pyx_tuple__34);
  9229. __pyx_tuple__35 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9230. __Pyx_GOTREF(__pyx_tuple__35);
  9231. __Pyx_GIVEREF(__pyx_tuple__35);
  9232. /* "lib/Naked/toolshed/c/file.pyx":297
  9233. * except Exception as e:
  9234. * if DEBUG_FLAG:
  9235. * sys.stderr.write("Naked Framework Error: unable to read lines in the specified encoding with the readlines_as method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  9236. * raise e
  9237. *
  9238. */
  9239. __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_s_Naked_Framework_Error_unable_to_3); if (unlikely(!__pyx_tuple__36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9240. __Pyx_GOTREF(__pyx_tuple__36);
  9241. __Pyx_GIVEREF(__pyx_tuple__36);
  9242. /* "lib/Naked/toolshed/c/file.pyx":309
  9243. * try:
  9244. * import codecs
  9245. * with codecs.open(self.filepath, encoding='utf-8', mode='r') as uni_reader: # <<<<<<<<<<<<<<
  9246. * modified_text_list = []
  9247. * for line in uni_reader:
  9248. */
  9249. __pyx_tuple__37 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9250. __Pyx_GOTREF(__pyx_tuple__37);
  9251. __Pyx_GIVEREF(__pyx_tuple__37);
  9252. __pyx_tuple__38 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9253. __Pyx_GOTREF(__pyx_tuple__38);
  9254. __Pyx_GIVEREF(__pyx_tuple__38);
  9255. /* "lib/Naked/toolshed/c/file.pyx":318
  9256. * except Exception as e:
  9257. * if DEBUG_FLAG:
  9258. * sys.stderr.write("Naked Framework Error: unable to read lines in the unicode file with the readlines_utf8 method (Naked.toolshed.file.py)") # <<<<<<<<<<<<<<
  9259. * raise e
  9260. *
  9261. */
  9262. __pyx_tuple__39 = PyTuple_Pack(1, __pyx_kp_s_Naked_Framework_Error_unable_to_4); if (unlikely(!__pyx_tuple__39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9263. __Pyx_GOTREF(__pyx_tuple__39);
  9264. __Pyx_GIVEREF(__pyx_tuple__39);
  9265. /* "lib/Naked/toolshed/c/file.pyx":332
  9266. * try:
  9267. * import gzip
  9268. * with gzip.open(self.filepath, 'rb') as gzip_reader: # <<<<<<<<<<<<<<
  9269. * file_data = gzip_reader.read()
  9270. * if encoding in ["utf-8", "utf8", "utf_8", "UTF-8", "UTF8", "UTF_8"]:
  9271. */
  9272. __pyx_tuple__40 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9273. __Pyx_GOTREF(__pyx_tuple__40);
  9274. __Pyx_GIVEREF(__pyx_tuple__40);
  9275. __pyx_tuple__41 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__41)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9276. __Pyx_GOTREF(__pyx_tuple__41);
  9277. __Pyx_GIVEREF(__pyx_tuple__41);
  9278. /* "lib/Naked/toolshed/c/file.pyx":344
  9279. * except Exception as e:
  9280. * if DEBUG_FLAG:
  9281. * sys.stderr.write("Naked Framework Error: Unable to read from the gzip compressed file with the read_gzip() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  9282. * raise e
  9283. *
  9284. */
  9285. __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_s_Naked_Framework_Error_Unable_to_13); if (unlikely(!__pyx_tuple__42)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9286. __Pyx_GOTREF(__pyx_tuple__42);
  9287. __Pyx_GIVEREF(__pyx_tuple__42);
  9288. /* "lib/Naked/toolshed/c/file.pyx":361
  9289. * except IOError as ioe:
  9290. * if DEBUG_FLAG:
  9291. * sys.stderr.write("Naked Framework Error: Unable to open file for read with read_utf8() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  9292. * raise ioe
  9293. * try:
  9294. */
  9295. __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_s_Naked_Framework_Error_Unable_to_14); if (unlikely(!__pyx_tuple__43)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9296. __Pyx_GOTREF(__pyx_tuple__43);
  9297. __Pyx_GIVEREF(__pyx_tuple__43);
  9298. /* "lib/Naked/toolshed/c/file.pyx":370
  9299. * except Exception as e:
  9300. * if DEBUG_FLAG:
  9301. * sys.stderr.write("Naked Framework Error: Unable to read the file with UTF-8 encoding using the read_utf8() method (Naked.toolshed.file.py).") # <<<<<<<<<<<<<<
  9302. * raise e
  9303. * finally:
  9304. */
  9305. __pyx_tuple__44 = PyTuple_Pack(1, __pyx_kp_s_Naked_Framework_Error_Unable_to_15); if (unlikely(!__pyx_tuple__44)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9306. __Pyx_GOTREF(__pyx_tuple__44);
  9307. __Pyx_GIVEREF(__pyx_tuple__44);
  9308. /* "lib/Naked/toolshed/c/file.pyx":13
  9309. * #------------------------------------------------------------------------------
  9310. * class IO:
  9311. * def __init__(self,filepath): # <<<<<<<<<<<<<<
  9312. * self.filepath = filepath
  9313. *
  9314. */
  9315. __pyx_tuple__45 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_filepath); if (unlikely(!__pyx_tuple__45)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9316. __Pyx_GOTREF(__pyx_tuple__45);
  9317. __Pyx_GIVEREF(__pyx_tuple__45);
  9318. __pyx_codeobj__46 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__45, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_init, 13, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__46)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9319. /* "lib/Naked/toolshed/c/file.pyx":21
  9320. * #------------------------------------------------------------------------------
  9321. * class FileWriter(IO):
  9322. * def __init__(self, filepath): # <<<<<<<<<<<<<<
  9323. * IO.__init__(self, filepath)
  9324. *
  9325. */
  9326. __pyx_tuple__47 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_filepath); if (unlikely(!__pyx_tuple__47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9327. __Pyx_GOTREF(__pyx_tuple__47);
  9328. __Pyx_GIVEREF(__pyx_tuple__47);
  9329. __pyx_codeobj__48 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_init, 21, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__48)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9330. /* "lib/Naked/toolshed/c/file.pyx":29
  9331. * # Tests: test_IO.py:: test_file_ascii_readwrite_append, test_file_append_missingfile
  9332. * #------------------------------------------------------------------------------
  9333. * def append(self, text): # <<<<<<<<<<<<<<
  9334. * try:
  9335. * from Naked.toolshed.system import file_exists
  9336. */
  9337. __pyx_tuple__49 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_text, __pyx_n_s_file_exists, __pyx_n_s_appender, __pyx_n_s_ue, __pyx_n_s_e); if (unlikely(!__pyx_tuple__49)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9338. __Pyx_GOTREF(__pyx_tuple__49);
  9339. __Pyx_GIVEREF(__pyx_tuple__49);
  9340. __pyx_codeobj__50 = (PyObject*)__Pyx_PyCode_New(2, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__49, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_append, 29, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__50)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9341. /* "lib/Naked/toolshed/c/file.pyx":48
  9342. * # Tests: test_IO.py :: test_file_utf8_readwrite_append
  9343. * #------------------------------------------------------------------------------
  9344. * def append_utf8(self, text): # <<<<<<<<<<<<<<
  9345. * try:
  9346. * from Naked.toolshed.system import file_exists
  9347. */
  9348. __pyx_tuple__51 = PyTuple_Pack(8, __pyx_n_s_self, __pyx_n_s_text, __pyx_n_s_file_exists, __pyx_n_s_codecs, __pyx_n_s_unicodedata, __pyx_n_s_norm_text, __pyx_n_s_appender, __pyx_n_s_e); if (unlikely(!__pyx_tuple__51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9349. __Pyx_GOTREF(__pyx_tuple__51);
  9350. __Pyx_GIVEREF(__pyx_tuple__51);
  9351. __pyx_codeobj__52 = (PyObject*)__Pyx_PyCode_New(2, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__51, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_append_utf8, 48, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9352. /* "lib/Naked/toolshed/c/file.pyx":71
  9353. * # test_file_gzip_utf8_readwrite_explicit_decode
  9354. * #------------------------------------------------------------------------------
  9355. * def gzip(self, text, compression_level=6): # <<<<<<<<<<<<<<
  9356. * try:
  9357. * import gzip
  9358. */
  9359. __pyx_tuple__53 = PyTuple_Pack(11, __pyx_n_s_self, __pyx_n_s_text, __pyx_n_s_compression_level, __pyx_n_s_gzip, __pyx_n_s_gzip_writer, __pyx_n_s_ue, __pyx_n_s_unicodedata, __pyx_n_s_norm_text, __pyx_n_s_codecs, __pyx_n_s_binary_data, __pyx_n_s_e); if (unlikely(!__pyx_tuple__53)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9360. __Pyx_GOTREF(__pyx_tuple__53);
  9361. __Pyx_GIVEREF(__pyx_tuple__53);
  9362. __pyx_codeobj__54 = (PyObject*)__Pyx_PyCode_New(3, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__53, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_gzip, 71, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__54)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9363. __pyx_tuple__55 = PyTuple_Pack(1, ((PyObject *)__pyx_int_6)); if (unlikely(!__pyx_tuple__55)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9364. __Pyx_GOTREF(__pyx_tuple__55);
  9365. __Pyx_GIVEREF(__pyx_tuple__55);
  9366. /* "lib/Naked/toolshed/c/file.pyx":96
  9367. * # test_file_utf8_write_raises_unicodeerror
  9368. * #------------------------------------------------------------------------------
  9369. * def write(self, text): # <<<<<<<<<<<<<<
  9370. * try:
  9371. * with open(self.filepath, 'wt') as writer:
  9372. */
  9373. __pyx_tuple__56 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_text, __pyx_n_s_writer, __pyx_n_s_ue, __pyx_n_s_e); if (unlikely(!__pyx_tuple__56)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9374. __Pyx_GOTREF(__pyx_tuple__56);
  9375. __Pyx_GIVEREF(__pyx_tuple__56);
  9376. __pyx_codeobj__57 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__56, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_write, 96, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__57)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9377. /* "lib/Naked/toolshed/c/file.pyx":112
  9378. * # Tests: test_IO.py :: test_file_utf8_readas_writeas
  9379. * #------------------------------------------------------------------------------
  9380. * def write_as(self, text, the_encoding=""): # <<<<<<<<<<<<<<
  9381. * try:
  9382. * if the_encoding == "": #if the developer did not include the encoding type, raise an exception
  9383. */
  9384. __pyx_tuple__58 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_text, __pyx_n_s_the_encoding, __pyx_n_s_codecs, __pyx_n_s_f, __pyx_n_s_e); if (unlikely(!__pyx_tuple__58)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9385. __Pyx_GOTREF(__pyx_tuple__58);
  9386. __Pyx_GIVEREF(__pyx_tuple__58);
  9387. __pyx_codeobj__59 = (PyObject*)__Pyx_PyCode_New(3, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__58, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_write_as, 112, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__59)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9388. __pyx_tuple__60 = PyTuple_Pack(1, ((PyObject*)__pyx_kp_s__13)); if (unlikely(!__pyx_tuple__60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9389. __Pyx_GOTREF(__pyx_tuple__60);
  9390. __Pyx_GIVEREF(__pyx_tuple__60);
  9391. /* "lib/Naked/toolshed/c/file.pyx":129
  9392. * # Tests: test_IO.py :: test_file_bin_readwrite
  9393. * #------------------------------------------------------------------------------
  9394. * def write_bin(self, binary_data): # <<<<<<<<<<<<<<
  9395. * try:
  9396. * with open(self.filepath, 'wb') as bin_writer:
  9397. */
  9398. __pyx_tuple__61 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_binary_data, __pyx_n_s_bin_writer, __pyx_n_s_e); if (unlikely(!__pyx_tuple__61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9399. __Pyx_GOTREF(__pyx_tuple__61);
  9400. __Pyx_GIVEREF(__pyx_tuple__61);
  9401. __pyx_codeobj__62 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__61, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_write_bin, 129, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__62)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9402. /* "lib/Naked/toolshed/c/file.pyx":144
  9403. * # Tests: test_IO.py :: test_file_ascii_safewrite, test_file_utf8_safewrite
  9404. * #------------------------------------------------------------------------------
  9405. * def safe_write(self, text): # <<<<<<<<<<<<<<
  9406. * import os.path
  9407. * if not os.path.exists(self.filepath): # if the file does not exist, then can write
  9408. */
  9409. __pyx_tuple__63 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_text, __pyx_n_s_os, __pyx_n_s_writer, __pyx_n_s_ue, __pyx_n_s_e); if (unlikely(!__pyx_tuple__63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9410. __Pyx_GOTREF(__pyx_tuple__63);
  9411. __Pyx_GIVEREF(__pyx_tuple__63);
  9412. __pyx_codeobj__64 = (PyObject*)__Pyx_PyCode_New(2, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__63, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_safe_write, 144, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9413. /* "lib/Naked/toolshed/c/file.pyx":166
  9414. * # returns boolean indicator for success of write based upon test for existence of file (False = write failed because file exists)
  9415. * #------------------------------------------------------------------------------
  9416. * def safe_write_bin(self, file_data): # <<<<<<<<<<<<<<
  9417. * try:
  9418. * import os.path
  9419. */
  9420. __pyx_tuple__65 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_file_data, __pyx_n_s_os, __pyx_n_s_writer, __pyx_n_s_e); if (unlikely(!__pyx_tuple__65)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9421. __Pyx_GOTREF(__pyx_tuple__65);
  9422. __Pyx_GIVEREF(__pyx_tuple__65);
  9423. __pyx_codeobj__66 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__65, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_safe_write_bin, 166, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__66)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9424. /* "lib/Naked/toolshed/c/file.pyx":188
  9425. * # Tests: test_IO.py :: test_file_utf8_readwrite, test_file_utf8_readwrite_raises_unicodeerror
  9426. * #------------------------------------------------------------------------------
  9427. * def write_utf8(self, text): # <<<<<<<<<<<<<<
  9428. * try:
  9429. * import codecs
  9430. */
  9431. __pyx_tuple__67 = PyTuple_Pack(8, __pyx_n_s_self, __pyx_n_s_text, __pyx_n_s_codecs, __pyx_n_s_f, __pyx_n_s_ioe, __pyx_n_s_unicodedata, __pyx_n_s_norm_text, __pyx_n_s_e); if (unlikely(!__pyx_tuple__67)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9432. __Pyx_GOTREF(__pyx_tuple__67);
  9433. __Pyx_GIVEREF(__pyx_tuple__67);
  9434. __pyx_codeobj__68 = (PyObject*)__Pyx_PyCode_New(2, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__67, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_write_utf8, 188, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__68)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9435. /* "lib/Naked/toolshed/c/file.pyx":213
  9436. * #------------------------------------------------------------------------------
  9437. * class FileReader(IO):
  9438. * def __init__(self, filepath): # <<<<<<<<<<<<<<
  9439. * IO.__init__(self, filepath)
  9440. *
  9441. */
  9442. __pyx_tuple__69 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_filepath); if (unlikely(!__pyx_tuple__69)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9443. __Pyx_GOTREF(__pyx_tuple__69);
  9444. __Pyx_GIVEREF(__pyx_tuple__69);
  9445. __pyx_codeobj__70 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__69, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_init, 213, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__70)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9446. /* "lib/Naked/toolshed/c/file.pyx":222
  9447. * # Tests: test_IO.py :: test_file_ascii_readwrite, test_file_read_missing_file,
  9448. * #------------------------------------------------------------------------------
  9449. * def read(self): # <<<<<<<<<<<<<<
  9450. * try:
  9451. * return self.read_utf8() #reads everything as unicode in utf8 encoding
  9452. */
  9453. __pyx_tuple__71 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_e); if (unlikely(!__pyx_tuple__71)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9454. __Pyx_GOTREF(__pyx_tuple__71);
  9455. __Pyx_GIVEREF(__pyx_tuple__71);
  9456. __pyx_codeobj__72 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__71, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_read, 222, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__72)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9457. /* "lib/Naked/toolshed/c/file.pyx":236
  9458. * # Tests: test_IO.py :: test_file_bin_readwrite, test_file_read_bin_missing_file
  9459. * #------------------------------------------------------------------------------
  9460. * def read_bin(self): # <<<<<<<<<<<<<<
  9461. * try:
  9462. * with open(self.filepath, 'rb') as bin_reader:
  9463. */
  9464. __pyx_tuple__73 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_bin_reader, __pyx_n_s_data, __pyx_n_s_e); if (unlikely(!__pyx_tuple__73)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9465. __Pyx_GOTREF(__pyx_tuple__73);
  9466. __Pyx_GIVEREF(__pyx_tuple__73);
  9467. __pyx_codeobj__74 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__73, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_read_bin, 236, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__74)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9468. /* "lib/Naked/toolshed/c/file.pyx":252
  9469. * # Tests: test_IO.py :: test_file_utf8_readas_writeas, test_file_readas_missing_file
  9470. * #------------------------------------------------------------------------------
  9471. * def read_as(self, the_encoding): # <<<<<<<<<<<<<<
  9472. * try:
  9473. * if the_encoding == "":
  9474. */
  9475. __pyx_tuple__75 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_the_encoding, __pyx_n_s_codecs, __pyx_n_s_f, __pyx_n_s_data, __pyx_n_s_e); if (unlikely(!__pyx_tuple__75)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9476. __Pyx_GOTREF(__pyx_tuple__75);
  9477. __Pyx_GIVEREF(__pyx_tuple__75);
  9478. __pyx_codeobj__76 = (PyObject*)__Pyx_PyCode_New(2, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__75, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_read_as, 252, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__76)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9479. /* "lib/Naked/toolshed/c/file.pyx":271
  9480. * # Tests: test_IO.py :: test_file_readlines, test_file_readlines_missing_file
  9481. * #------------------------------------------------------------------------------
  9482. * def readlines(self): # <<<<<<<<<<<<<<
  9483. * try:
  9484. * return self.readlines_utf8() # read as utf8 encoded file
  9485. */
  9486. __pyx_tuple__77 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_e); if (unlikely(!__pyx_tuple__77)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9487. __Pyx_GOTREF(__pyx_tuple__77);
  9488. __Pyx_GIVEREF(__pyx_tuple__77);
  9489. __pyx_codeobj__78 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__77, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_readlines, 271, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__78)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9490. /* "lib/Naked/toolshed/c/file.pyx":285
  9491. * # Tests: test_IO.py ::
  9492. * #------------------------------------------------------------------------------
  9493. * def readlines_as(self, dev_spec_encoding): # <<<<<<<<<<<<<<
  9494. * try:
  9495. * if dev_spec_encoding == "":
  9496. */
  9497. __pyx_tuple__79 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_dev_spec_encoding, __pyx_n_s_codecs, __pyx_n_s_reader, __pyx_n_s_data_list, __pyx_n_s_line, __pyx_n_s_e); if (unlikely(!__pyx_tuple__79)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9498. __Pyx_GOTREF(__pyx_tuple__79);
  9499. __Pyx_GIVEREF(__pyx_tuple__79);
  9500. __pyx_codeobj__80 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__79, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_readlines_as, 285, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__80)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9501. /* "lib/Naked/toolshed/c/file.pyx":306
  9502. * # Tests: test_IO.py :: test_file_readlines_unicode, test_file_readlines_utf8_missing_file
  9503. * #------------------------------------------------------------------------------
  9504. * def readlines_utf8(self): # <<<<<<<<<<<<<<
  9505. * try:
  9506. * import codecs
  9507. */
  9508. __pyx_tuple__81 = PyTuple_Pack(8, __pyx_n_s_self, __pyx_n_s_codecs, __pyx_n_s_uni_reader, __pyx_n_s_modified_text_list, __pyx_n_s_line, __pyx_n_s_unicodedata, __pyx_n_s_norm_line, __pyx_n_s_e); if (unlikely(!__pyx_tuple__81)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9509. __Pyx_GOTREF(__pyx_tuple__81);
  9510. __Pyx_GIVEREF(__pyx_tuple__81);
  9511. __pyx_codeobj__82 = (PyObject*)__Pyx_PyCode_New(1, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__81, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_readlines_utf8, 306, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__82)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9512. /* "lib/Naked/toolshed/c/file.pyx":329
  9513. * # test_file_read_gzip_missing_file
  9514. * #------------------------------------------------------------------------------
  9515. * def read_gzip(self, encoding="system_default"): # <<<<<<<<<<<<<<
  9516. * try:
  9517. * import gzip
  9518. */
  9519. __pyx_tuple__83 = PyTuple_Pack(9, __pyx_n_s_self, __pyx_n_s_encoding, __pyx_n_s_gzip, __pyx_n_s_gzip_reader, __pyx_n_s_file_data, __pyx_n_s_codecs, __pyx_n_s_unicodedata, __pyx_n_s_norm_data, __pyx_n_s_e); if (unlikely(!__pyx_tuple__83)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9520. __Pyx_GOTREF(__pyx_tuple__83);
  9521. __Pyx_GIVEREF(__pyx_tuple__83);
  9522. __pyx_codeobj__84 = (PyObject*)__Pyx_PyCode_New(2, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__83, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_read_gzip, 329, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__84)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9523. __pyx_tuple__85 = PyTuple_Pack(1, ((PyObject*)__pyx_n_s_system_default)); if (unlikely(!__pyx_tuple__85)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9524. __Pyx_GOTREF(__pyx_tuple__85);
  9525. __Pyx_GIVEREF(__pyx_tuple__85);
  9526. /* "lib/Naked/toolshed/c/file.pyx":355
  9527. * # test_file_read_utf8_missing_file
  9528. * #------------------------------------------------------------------------------
  9529. * def read_utf8(self): # <<<<<<<<<<<<<<
  9530. * try:
  9531. * import codecs
  9532. */
  9533. __pyx_tuple__86 = PyTuple_Pack(8, __pyx_n_s_self, __pyx_n_s_codecs, __pyx_n_s_f, __pyx_n_s_ioe, __pyx_n_s_textstring, __pyx_n_s_unicodedata, __pyx_n_s_norm_text, __pyx_n_s_e); if (unlikely(!__pyx_tuple__86)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9534. __Pyx_GOTREF(__pyx_tuple__86);
  9535. __Pyx_GIVEREF(__pyx_tuple__86);
  9536. __pyx_codeobj__87 = (PyObject*)__Pyx_PyCode_New(1, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__86, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_read_utf8, 355, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__87)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9537. __Pyx_RefNannyFinishContext();
  9538. return 0;
  9539. __pyx_L1_error:;
  9540. __Pyx_RefNannyFinishContext();
  9541. return -1;
  9542. }
  9543. static int __Pyx_InitGlobals(void) {
  9544. if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  9545. __pyx_int_6 = PyInt_FromLong(6); if (unlikely(!__pyx_int_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9546. return 0;
  9547. __pyx_L1_error:;
  9548. return -1;
  9549. }
  9550. #if PY_MAJOR_VERSION < 3
  9551. PyMODINIT_FUNC initfile(void); /*proto*/
  9552. PyMODINIT_FUNC initfile(void)
  9553. #else
  9554. PyMODINIT_FUNC PyInit_file(void); /*proto*/
  9555. PyMODINIT_FUNC PyInit_file(void)
  9556. #endif
  9557. {
  9558. PyObject *__pyx_t_1 = NULL;
  9559. PyObject *__pyx_t_2 = NULL;
  9560. PyObject *__pyx_t_3 = NULL;
  9561. PyObject *__pyx_t_4 = NULL;
  9562. int __pyx_t_5;
  9563. int __pyx_lineno = 0;
  9564. const char *__pyx_filename = NULL;
  9565. int __pyx_clineno = 0;
  9566. __Pyx_RefNannyDeclarations
  9567. #if CYTHON_REFNANNY
  9568. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  9569. if (!__Pyx_RefNanny) {
  9570. PyErr_Clear();
  9571. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  9572. if (!__Pyx_RefNanny)
  9573. Py_FatalError("failed to import 'refnanny' module");
  9574. }
  9575. #endif
  9576. __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_file(void)", 0);
  9577. if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9578. __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9579. __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9580. #ifdef __Pyx_CyFunction_USED
  9581. if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9582. #endif
  9583. #ifdef __Pyx_FusedFunction_USED
  9584. if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9585. #endif
  9586. #ifdef __Pyx_Generator_USED
  9587. if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9588. #endif
  9589. /*--- Library function declarations ---*/
  9590. /*--- Threads initialization code ---*/
  9591. #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  9592. #ifdef WITH_THREAD /* Python build with threading support? */
  9593. PyEval_InitThreads();
  9594. #endif
  9595. #endif
  9596. /*--- Module creation code ---*/
  9597. #if PY_MAJOR_VERSION < 3
  9598. __pyx_m = Py_InitModule4(__Pyx_NAMESTR("file"), __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  9599. #else
  9600. __pyx_m = PyModule_Create(&__pyx_moduledef);
  9601. #endif
  9602. if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9603. __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9604. Py_INCREF(__pyx_d);
  9605. __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9606. #if CYTHON_COMPILING_IN_PYPY
  9607. Py_INCREF(__pyx_b);
  9608. #endif
  9609. if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  9610. /*--- Initialize various global constants etc. ---*/
  9611. if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9612. #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  9613. if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9614. #endif
  9615. if (__pyx_module_is_main_lib__Naked__toolshed__c__file) {
  9616. if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  9617. }
  9618. #if PY_MAJOR_VERSION >= 3
  9619. {
  9620. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9621. if (!PyDict_GetItemString(modules, "lib.Naked.toolshed.c.file")) {
  9622. if (unlikely(PyDict_SetItemString(modules, "lib.Naked.toolshed.c.file", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9623. }
  9624. }
  9625. #endif
  9626. /*--- Builtin init code ---*/
  9627. if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9628. /*--- Constants init code ---*/
  9629. if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9630. /*--- Global init code ---*/
  9631. /*--- Variable export code ---*/
  9632. /*--- Function export code ---*/
  9633. /*--- Type init code ---*/
  9634. /*--- Type import code ---*/
  9635. /*--- Variable import code ---*/
  9636. /*--- Function import code ---*/
  9637. /*--- Execution code ---*/
  9638. /* "lib/Naked/toolshed/c/file.pyx":5
  9639. * # cython: profile=False
  9640. *
  9641. * import sys # <<<<<<<<<<<<<<
  9642. * from Naked.settings import debug as DEBUG_FLAG
  9643. *
  9644. */
  9645. __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9646. __Pyx_GOTREF(__pyx_t_1);
  9647. if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9648. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9649. /* "lib/Naked/toolshed/c/file.pyx":6
  9650. *
  9651. * import sys
  9652. * from Naked.settings import debug as DEBUG_FLAG # <<<<<<<<<<<<<<
  9653. *
  9654. * #------------------------------------------------------------------------------
  9655. */
  9656. __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9657. __Pyx_GOTREF(__pyx_t_1);
  9658. __Pyx_INCREF(__pyx_n_s_debug);
  9659. PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_debug);
  9660. __Pyx_GIVEREF(__pyx_n_s_debug);
  9661. __pyx_t_2 = __Pyx_Import(__pyx_n_s_Naked_settings, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9662. __Pyx_GOTREF(__pyx_t_2);
  9663. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9664. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9665. __Pyx_GOTREF(__pyx_t_1);
  9666. if (PyDict_SetItem(__pyx_d, __pyx_n_s_DEBUG_FLAG, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9667. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9668. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9669. /* "lib/Naked/toolshed/c/file.pyx":12
  9670. * # interface for all local file IO classes
  9671. * #------------------------------------------------------------------------------
  9672. * class IO: # <<<<<<<<<<<<<<
  9673. * def __init__(self,filepath):
  9674. * self.filepath = filepath
  9675. */
  9676. __pyx_t_2 = __Pyx_Py3MetaclassPrepare((PyObject *) NULL, __pyx_empty_tuple, __pyx_n_s_IO, __pyx_n_s_IO, (PyObject *) NULL, __pyx_n_s_lib_Naked_toolshed_c_file, (PyObject *) NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9677. __Pyx_GOTREF(__pyx_t_2);
  9678. /* "lib/Naked/toolshed/c/file.pyx":13
  9679. * #------------------------------------------------------------------------------
  9680. * class IO:
  9681. * def __init__(self,filepath): # <<<<<<<<<<<<<<
  9682. * self.filepath = filepath
  9683. *
  9684. */
  9685. __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_2IO_1__init__, 0, __pyx_n_s_IO___init, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__46)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9686. __Pyx_GOTREF(__pyx_t_1);
  9687. if (PyObject_SetItem(__pyx_t_2, __pyx_n_s_init, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9688. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9689. /* "lib/Naked/toolshed/c/file.pyx":12
  9690. * # interface for all local file IO classes
  9691. * #------------------------------------------------------------------------------
  9692. * class IO: # <<<<<<<<<<<<<<
  9693. * def __init__(self,filepath):
  9694. * self.filepath = filepath
  9695. */
  9696. __pyx_t_1 = __Pyx_Py3ClassCreate(((PyObject*)&__Pyx_DefaultClassType), __pyx_n_s_IO, __pyx_empty_tuple, __pyx_t_2, NULL, 0, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9697. __Pyx_GOTREF(__pyx_t_1);
  9698. if (PyDict_SetItem(__pyx_d, __pyx_n_s_IO, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9699. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9700. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9701. /* "lib/Naked/toolshed/c/file.pyx":20
  9702. * # writes data to local files
  9703. * #------------------------------------------------------------------------------
  9704. * class FileWriter(IO): # <<<<<<<<<<<<<<
  9705. * def __init__(self, filepath):
  9706. * IO.__init__(self, filepath)
  9707. */
  9708. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_IO); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9709. __Pyx_GOTREF(__pyx_t_2);
  9710. __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9711. __Pyx_GOTREF(__pyx_t_1);
  9712. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  9713. __Pyx_GIVEREF(__pyx_t_2);
  9714. __pyx_t_2 = 0;
  9715. __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9716. __Pyx_GOTREF(__pyx_t_2);
  9717. __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_FileWriter, __pyx_n_s_FileWriter, (PyObject *) NULL, __pyx_n_s_lib_Naked_toolshed_c_file, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9718. __Pyx_GOTREF(__pyx_t_3);
  9719. /* "lib/Naked/toolshed/c/file.pyx":21
  9720. * #------------------------------------------------------------------------------
  9721. * class FileWriter(IO):
  9722. * def __init__(self, filepath): # <<<<<<<<<<<<<<
  9723. * IO.__init__(self, filepath)
  9724. *
  9725. */
  9726. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_1__init__, 0, __pyx_n_s_FileWriter___init, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__48)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9727. __Pyx_GOTREF(__pyx_t_4);
  9728. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_init, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9729. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9730. /* "lib/Naked/toolshed/c/file.pyx":29
  9731. * # Tests: test_IO.py:: test_file_ascii_readwrite_append, test_file_append_missingfile
  9732. * #------------------------------------------------------------------------------
  9733. * def append(self, text): # <<<<<<<<<<<<<<
  9734. * try:
  9735. * from Naked.toolshed.system import file_exists
  9736. */
  9737. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_3append, 0, __pyx_n_s_FileWriter_append, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__50)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9738. __Pyx_GOTREF(__pyx_t_4);
  9739. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_append, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9740. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9741. /* "lib/Naked/toolshed/c/file.pyx":48
  9742. * # Tests: test_IO.py :: test_file_utf8_readwrite_append
  9743. * #------------------------------------------------------------------------------
  9744. * def append_utf8(self, text): # <<<<<<<<<<<<<<
  9745. * try:
  9746. * from Naked.toolshed.system import file_exists
  9747. */
  9748. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_5append_utf8, 0, __pyx_n_s_FileWriter_append_utf8, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__52)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9749. __Pyx_GOTREF(__pyx_t_4);
  9750. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_append_utf8, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9751. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9752. /* "lib/Naked/toolshed/c/file.pyx":71
  9753. * # test_file_gzip_utf8_readwrite_explicit_decode
  9754. * #------------------------------------------------------------------------------
  9755. * def gzip(self, text, compression_level=6): # <<<<<<<<<<<<<<
  9756. * try:
  9757. * import gzip
  9758. */
  9759. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_7gzip, 0, __pyx_n_s_FileWriter_gzip, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__54)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9760. __Pyx_GOTREF(__pyx_t_4);
  9761. __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__55);
  9762. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_gzip, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9763. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9764. /* "lib/Naked/toolshed/c/file.pyx":96
  9765. * # test_file_utf8_write_raises_unicodeerror
  9766. * #------------------------------------------------------------------------------
  9767. * def write(self, text): # <<<<<<<<<<<<<<
  9768. * try:
  9769. * with open(self.filepath, 'wt') as writer:
  9770. */
  9771. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_9write, 0, __pyx_n_s_FileWriter_write, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__57)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9772. __Pyx_GOTREF(__pyx_t_4);
  9773. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_write, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9774. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9775. /* "lib/Naked/toolshed/c/file.pyx":112
  9776. * # Tests: test_IO.py :: test_file_utf8_readas_writeas
  9777. * #------------------------------------------------------------------------------
  9778. * def write_as(self, text, the_encoding=""): # <<<<<<<<<<<<<<
  9779. * try:
  9780. * if the_encoding == "": #if the developer did not include the encoding type, raise an exception
  9781. */
  9782. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_11write_as, 0, __pyx_n_s_FileWriter_write_as, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__59)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9783. __Pyx_GOTREF(__pyx_t_4);
  9784. __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__60);
  9785. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_write_as, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9786. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9787. /* "lib/Naked/toolshed/c/file.pyx":129
  9788. * # Tests: test_IO.py :: test_file_bin_readwrite
  9789. * #------------------------------------------------------------------------------
  9790. * def write_bin(self, binary_data): # <<<<<<<<<<<<<<
  9791. * try:
  9792. * with open(self.filepath, 'wb') as bin_writer:
  9793. */
  9794. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_13write_bin, 0, __pyx_n_s_FileWriter_write_bin, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__62)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9795. __Pyx_GOTREF(__pyx_t_4);
  9796. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_write_bin, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9797. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9798. /* "lib/Naked/toolshed/c/file.pyx":144
  9799. * # Tests: test_IO.py :: test_file_ascii_safewrite, test_file_utf8_safewrite
  9800. * #------------------------------------------------------------------------------
  9801. * def safe_write(self, text): # <<<<<<<<<<<<<<
  9802. * import os.path
  9803. * if not os.path.exists(self.filepath): # if the file does not exist, then can write
  9804. */
  9805. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_15safe_write, 0, __pyx_n_s_FileWriter_safe_write, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__64)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9806. __Pyx_GOTREF(__pyx_t_4);
  9807. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_safe_write, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9808. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9809. /* "lib/Naked/toolshed/c/file.pyx":166
  9810. * # returns boolean indicator for success of write based upon test for existence of file (False = write failed because file exists)
  9811. * #------------------------------------------------------------------------------
  9812. * def safe_write_bin(self, file_data): # <<<<<<<<<<<<<<
  9813. * try:
  9814. * import os.path
  9815. */
  9816. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_17safe_write_bin, 0, __pyx_n_s_FileWriter_safe_write_bin, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__66)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9817. __Pyx_GOTREF(__pyx_t_4);
  9818. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_safe_write_bin, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9819. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9820. /* "lib/Naked/toolshed/c/file.pyx":188
  9821. * # Tests: test_IO.py :: test_file_utf8_readwrite, test_file_utf8_readwrite_raises_unicodeerror
  9822. * #------------------------------------------------------------------------------
  9823. * def write_utf8(self, text): # <<<<<<<<<<<<<<
  9824. * try:
  9825. * import codecs
  9826. */
  9827. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileWriter_19write_utf8, 0, __pyx_n_s_FileWriter_write_utf8, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__68)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9828. __Pyx_GOTREF(__pyx_t_4);
  9829. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_write_utf8, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9830. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9831. /* "lib/Naked/toolshed/c/file.pyx":20
  9832. * # writes data to local files
  9833. * #------------------------------------------------------------------------------
  9834. * class FileWriter(IO): # <<<<<<<<<<<<<<
  9835. * def __init__(self, filepath):
  9836. * IO.__init__(self, filepath)
  9837. */
  9838. __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_FileWriter, __pyx_t_1, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9839. __Pyx_GOTREF(__pyx_t_4);
  9840. if (PyDict_SetItem(__pyx_d, __pyx_n_s_FileWriter, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9841. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9842. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9843. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9844. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9845. /* "lib/Naked/toolshed/c/file.pyx":212
  9846. * # filename assigned in constructor (inherited from IO class interface)
  9847. * #------------------------------------------------------------------------------
  9848. * class FileReader(IO): # <<<<<<<<<<<<<<
  9849. * def __init__(self, filepath):
  9850. * IO.__init__(self, filepath)
  9851. */
  9852. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_IO); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9853. __Pyx_GOTREF(__pyx_t_1);
  9854. __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9855. __Pyx_GOTREF(__pyx_t_2);
  9856. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  9857. __Pyx_GIVEREF(__pyx_t_1);
  9858. __pyx_t_1 = 0;
  9859. __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9860. __Pyx_GOTREF(__pyx_t_1);
  9861. __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_2, __pyx_n_s_FileReader, __pyx_n_s_FileReader, (PyObject *) NULL, __pyx_n_s_lib_Naked_toolshed_c_file, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9862. __Pyx_GOTREF(__pyx_t_3);
  9863. /* "lib/Naked/toolshed/c/file.pyx":213
  9864. * #------------------------------------------------------------------------------
  9865. * class FileReader(IO):
  9866. * def __init__(self, filepath): # <<<<<<<<<<<<<<
  9867. * IO.__init__(self, filepath)
  9868. *
  9869. */
  9870. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileReader_1__init__, 0, __pyx_n_s_FileReader___init, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__70)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9871. __Pyx_GOTREF(__pyx_t_4);
  9872. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_init, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9873. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9874. /* "lib/Naked/toolshed/c/file.pyx":222
  9875. * # Tests: test_IO.py :: test_file_ascii_readwrite, test_file_read_missing_file,
  9876. * #------------------------------------------------------------------------------
  9877. * def read(self): # <<<<<<<<<<<<<<
  9878. * try:
  9879. * return self.read_utf8() #reads everything as unicode in utf8 encoding
  9880. */
  9881. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileReader_3read, 0, __pyx_n_s_FileReader_read, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__72)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9882. __Pyx_GOTREF(__pyx_t_4);
  9883. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_read, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9884. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9885. /* "lib/Naked/toolshed/c/file.pyx":236
  9886. * # Tests: test_IO.py :: test_file_bin_readwrite, test_file_read_bin_missing_file
  9887. * #------------------------------------------------------------------------------
  9888. * def read_bin(self): # <<<<<<<<<<<<<<
  9889. * try:
  9890. * with open(self.filepath, 'rb') as bin_reader:
  9891. */
  9892. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileReader_5read_bin, 0, __pyx_n_s_FileReader_read_bin, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__74)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9893. __Pyx_GOTREF(__pyx_t_4);
  9894. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_read_bin, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9895. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9896. /* "lib/Naked/toolshed/c/file.pyx":252
  9897. * # Tests: test_IO.py :: test_file_utf8_readas_writeas, test_file_readas_missing_file
  9898. * #------------------------------------------------------------------------------
  9899. * def read_as(self, the_encoding): # <<<<<<<<<<<<<<
  9900. * try:
  9901. * if the_encoding == "":
  9902. */
  9903. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileReader_7read_as, 0, __pyx_n_s_FileReader_read_as, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__76)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9904. __Pyx_GOTREF(__pyx_t_4);
  9905. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_read_as, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9906. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9907. /* "lib/Naked/toolshed/c/file.pyx":271
  9908. * # Tests: test_IO.py :: test_file_readlines, test_file_readlines_missing_file
  9909. * #------------------------------------------------------------------------------
  9910. * def readlines(self): # <<<<<<<<<<<<<<
  9911. * try:
  9912. * return self.readlines_utf8() # read as utf8 encoded file
  9913. */
  9914. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileReader_9readlines, 0, __pyx_n_s_FileReader_readlines, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__78)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9915. __Pyx_GOTREF(__pyx_t_4);
  9916. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_readlines, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9917. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9918. /* "lib/Naked/toolshed/c/file.pyx":285
  9919. * # Tests: test_IO.py ::
  9920. * #------------------------------------------------------------------------------
  9921. * def readlines_as(self, dev_spec_encoding): # <<<<<<<<<<<<<<
  9922. * try:
  9923. * if dev_spec_encoding == "":
  9924. */
  9925. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileReader_11readlines_as, 0, __pyx_n_s_FileReader_readlines_as, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__80)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9926. __Pyx_GOTREF(__pyx_t_4);
  9927. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_readlines_as, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9928. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9929. /* "lib/Naked/toolshed/c/file.pyx":306
  9930. * # Tests: test_IO.py :: test_file_readlines_unicode, test_file_readlines_utf8_missing_file
  9931. * #------------------------------------------------------------------------------
  9932. * def readlines_utf8(self): # <<<<<<<<<<<<<<
  9933. * try:
  9934. * import codecs
  9935. */
  9936. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileReader_13readlines_utf8, 0, __pyx_n_s_FileReader_readlines_utf8, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__82)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9937. __Pyx_GOTREF(__pyx_t_4);
  9938. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_readlines_utf8, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9939. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9940. /* "lib/Naked/toolshed/c/file.pyx":329
  9941. * # test_file_read_gzip_missing_file
  9942. * #------------------------------------------------------------------------------
  9943. * def read_gzip(self, encoding="system_default"): # <<<<<<<<<<<<<<
  9944. * try:
  9945. * import gzip
  9946. */
  9947. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileReader_15read_gzip, 0, __pyx_n_s_FileReader_read_gzip, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__84)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9948. __Pyx_GOTREF(__pyx_t_4);
  9949. __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__85);
  9950. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_read_gzip, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9951. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9952. /* "lib/Naked/toolshed/c/file.pyx":355
  9953. * # test_file_read_utf8_missing_file
  9954. * #------------------------------------------------------------------------------
  9955. * def read_utf8(self): # <<<<<<<<<<<<<<
  9956. * try:
  9957. * import codecs
  9958. */
  9959. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_4file_10FileReader_17read_utf8, 0, __pyx_n_s_FileReader_read_utf8, NULL, __pyx_n_s_lib_Naked_toolshed_c_file, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__87)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9960. __Pyx_GOTREF(__pyx_t_4);
  9961. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_read_utf8, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9962. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9963. /* "lib/Naked/toolshed/c/file.pyx":212
  9964. * # filename assigned in constructor (inherited from IO class interface)
  9965. * #------------------------------------------------------------------------------
  9966. * class FileReader(IO): # <<<<<<<<<<<<<<
  9967. * def __init__(self, filepath):
  9968. * IO.__init__(self, filepath)
  9969. */
  9970. __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_FileReader, __pyx_t_2, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9971. __Pyx_GOTREF(__pyx_t_4);
  9972. if (PyDict_SetItem(__pyx_d, __pyx_n_s_FileReader, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9973. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9974. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  9975. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9976. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9977. /* "lib/Naked/toolshed/c/file.pyx":376
  9978. *
  9979. *
  9980. * if __name__ == '__main__': # <<<<<<<<<<<<<<
  9981. * pass
  9982. */
  9983. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9984. __Pyx_GOTREF(__pyx_t_2);
  9985. __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_n_s_main, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9986. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9987. if (__pyx_t_5) {
  9988. goto __pyx_L2;
  9989. }
  9990. __pyx_L2:;
  9991. /* "lib/Naked/toolshed/c/file.pyx":1
  9992. * #!/usr/bin/env python # <<<<<<<<<<<<<<
  9993. * # encoding: utf-8
  9994. * # cython: profile=False
  9995. */
  9996. __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9997. __Pyx_GOTREF(__pyx_t_2);
  9998. if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  9999. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  10000. goto __pyx_L0;
  10001. __pyx_L1_error:;
  10002. __Pyx_XDECREF(__pyx_t_1);
  10003. __Pyx_XDECREF(__pyx_t_2);
  10004. __Pyx_XDECREF(__pyx_t_3);
  10005. __Pyx_XDECREF(__pyx_t_4);
  10006. if (__pyx_m) {
  10007. __Pyx_AddTraceback("init lib.Naked.toolshed.c.file", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10008. Py_DECREF(__pyx_m); __pyx_m = 0;
  10009. } else if (!PyErr_Occurred()) {
  10010. PyErr_SetString(PyExc_ImportError, "init lib.Naked.toolshed.c.file");
  10011. }
  10012. __pyx_L0:;
  10013. __Pyx_RefNannyFinishContext();
  10014. #if PY_MAJOR_VERSION < 3
  10015. return;
  10016. #else
  10017. return __pyx_m;
  10018. #endif
  10019. }
  10020. /* Runtime support code */
  10021. #if CYTHON_REFNANNY
  10022. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  10023. PyObject *m = NULL, *p = NULL;
  10024. void *r = NULL;
  10025. m = PyImport_ImportModule((char *)modname);
  10026. if (!m) goto end;
  10027. p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
  10028. if (!p) goto end;
  10029. r = PyLong_AsVoidPtr(p);
  10030. end:
  10031. Py_XDECREF(p);
  10032. Py_XDECREF(m);
  10033. return (__Pyx_RefNannyAPIStruct *)r;
  10034. }
  10035. #endif /* CYTHON_REFNANNY */
  10036. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  10037. PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
  10038. if (unlikely(!result)) {
  10039. PyErr_Format(PyExc_NameError,
  10040. #if PY_MAJOR_VERSION >= 3
  10041. "name '%U' is not defined", name);
  10042. #else
  10043. "name '%.200s' is not defined", PyString_AS_STRING(name));
  10044. #endif
  10045. }
  10046. return result;
  10047. }
  10048. static void __Pyx_RaiseArgtupleInvalid(
  10049. const char* func_name,
  10050. int exact,
  10051. Py_ssize_t num_min,
  10052. Py_ssize_t num_max,
  10053. Py_ssize_t num_found)
  10054. {
  10055. Py_ssize_t num_expected;
  10056. const char *more_or_less;
  10057. if (num_found < num_min) {
  10058. num_expected = num_min;
  10059. more_or_less = "at least";
  10060. } else {
  10061. num_expected = num_max;
  10062. more_or_less = "at most";
  10063. }
  10064. if (exact) {
  10065. more_or_less = "exactly";
  10066. }
  10067. PyErr_Format(PyExc_TypeError,
  10068. "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  10069. func_name, more_or_less, num_expected,
  10070. (num_expected == 1) ? "" : "s", num_found);
  10071. }
  10072. static void __Pyx_RaiseDoubleKeywordsError(
  10073. const char* func_name,
  10074. PyObject* kw_name)
  10075. {
  10076. PyErr_Format(PyExc_TypeError,
  10077. #if PY_MAJOR_VERSION >= 3
  10078. "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
  10079. #else
  10080. "%s() got multiple values for keyword argument '%s'", func_name,
  10081. PyString_AsString(kw_name));
  10082. #endif
  10083. }
  10084. static int __Pyx_ParseOptionalKeywords(
  10085. PyObject *kwds,
  10086. PyObject **argnames[],
  10087. PyObject *kwds2,
  10088. PyObject *values[],
  10089. Py_ssize_t num_pos_args,
  10090. const char* function_name)
  10091. {
  10092. PyObject *key = 0, *value = 0;
  10093. Py_ssize_t pos = 0;
  10094. PyObject*** name;
  10095. PyObject*** first_kw_arg = argnames + num_pos_args;
  10096. while (PyDict_Next(kwds, &pos, &key, &value)) {
  10097. name = first_kw_arg;
  10098. while (*name && (**name != key)) name++;
  10099. if (*name) {
  10100. values[name-argnames] = value;
  10101. continue;
  10102. }
  10103. name = first_kw_arg;
  10104. #if PY_MAJOR_VERSION < 3
  10105. if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
  10106. while (*name) {
  10107. if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
  10108. && _PyString_Eq(**name, key)) {
  10109. values[name-argnames] = value;
  10110. break;
  10111. }
  10112. name++;
  10113. }
  10114. if (*name) continue;
  10115. else {
  10116. PyObject*** argname = argnames;
  10117. while (argname != first_kw_arg) {
  10118. if ((**argname == key) || (
  10119. (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
  10120. && _PyString_Eq(**argname, key))) {
  10121. goto arg_passed_twice;
  10122. }
  10123. argname++;
  10124. }
  10125. }
  10126. } else
  10127. #endif
  10128. if (likely(PyUnicode_Check(key))) {
  10129. while (*name) {
  10130. int cmp = (**name == key) ? 0 :
  10131. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  10132. (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
  10133. #endif
  10134. PyUnicode_Compare(**name, key);
  10135. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  10136. if (cmp == 0) {
  10137. values[name-argnames] = value;
  10138. break;
  10139. }
  10140. name++;
  10141. }
  10142. if (*name) continue;
  10143. else {
  10144. PyObject*** argname = argnames;
  10145. while (argname != first_kw_arg) {
  10146. int cmp = (**argname == key) ? 0 :
  10147. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  10148. (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
  10149. #endif
  10150. PyUnicode_Compare(**argname, key);
  10151. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  10152. if (cmp == 0) goto arg_passed_twice;
  10153. argname++;
  10154. }
  10155. }
  10156. } else
  10157. goto invalid_keyword_type;
  10158. if (kwds2) {
  10159. if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
  10160. } else {
  10161. goto invalid_keyword;
  10162. }
  10163. }
  10164. return 0;
  10165. arg_passed_twice:
  10166. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  10167. goto bad;
  10168. invalid_keyword_type:
  10169. PyErr_Format(PyExc_TypeError,
  10170. "%.200s() keywords must be strings", function_name);
  10171. goto bad;
  10172. invalid_keyword:
  10173. PyErr_Format(PyExc_TypeError,
  10174. #if PY_MAJOR_VERSION < 3
  10175. "%.200s() got an unexpected keyword argument '%.200s'",
  10176. function_name, PyString_AsString(key));
  10177. #else
  10178. "%s() got an unexpected keyword argument '%U'",
  10179. function_name, key);
  10180. #endif
  10181. bad:
  10182. return -1;
  10183. }
  10184. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
  10185. PyObject *result;
  10186. #if CYTHON_COMPILING_IN_CPYTHON
  10187. result = PyDict_GetItem(__pyx_d, name);
  10188. if (result) {
  10189. Py_INCREF(result);
  10190. } else {
  10191. #else
  10192. result = PyObject_GetItem(__pyx_d, name);
  10193. if (!result) {
  10194. PyErr_Clear();
  10195. #endif
  10196. result = __Pyx_GetBuiltinName(name);
  10197. }
  10198. return result;
  10199. }
  10200. #if CYTHON_COMPILING_IN_CPYTHON
  10201. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  10202. PyObject *result;
  10203. ternaryfunc call = func->ob_type->tp_call;
  10204. if (unlikely(!call))
  10205. return PyObject_Call(func, arg, kw);
  10206. #if PY_VERSION_HEX >= 0x02060000
  10207. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  10208. return NULL;
  10209. #endif
  10210. result = (*call)(func, arg, kw);
  10211. #if PY_VERSION_HEX >= 0x02060000
  10212. Py_LeaveRecursiveCall();
  10213. #endif
  10214. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  10215. PyErr_SetString(
  10216. PyExc_SystemError,
  10217. "NULL result without error in PyObject_Call");
  10218. }
  10219. return result;
  10220. }
  10221. #endif
  10222. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
  10223. PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
  10224. if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
  10225. PyErr_Format(PyExc_ImportError,
  10226. #if PY_MAJOR_VERSION < 3
  10227. "cannot import name %.230s", PyString_AS_STRING(name));
  10228. #else
  10229. "cannot import name %S", name);
  10230. #endif
  10231. }
  10232. return value;
  10233. }
  10234. static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
  10235. #if CYTHON_COMPILING_IN_CPYTHON
  10236. PyObject *tmp_type, *tmp_value, *tmp_tb;
  10237. PyThreadState *tstate = PyThreadState_GET();
  10238. tmp_type = tstate->curexc_type;
  10239. tmp_value = tstate->curexc_value;
  10240. tmp_tb = tstate->curexc_traceback;
  10241. tstate->curexc_type = type;
  10242. tstate->curexc_value = value;
  10243. tstate->curexc_traceback = tb;
  10244. Py_XDECREF(tmp_type);
  10245. Py_XDECREF(tmp_value);
  10246. Py_XDECREF(tmp_tb);
  10247. #else
  10248. PyErr_Restore(type, value, tb);
  10249. #endif
  10250. }
  10251. static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
  10252. #if CYTHON_COMPILING_IN_CPYTHON
  10253. PyThreadState *tstate = PyThreadState_GET();
  10254. *type = tstate->curexc_type;
  10255. *value = tstate->curexc_value;
  10256. *tb = tstate->curexc_traceback;
  10257. tstate->curexc_type = 0;
  10258. tstate->curexc_value = 0;
  10259. tstate->curexc_traceback = 0;
  10260. #else
  10261. PyErr_Fetch(type, value, tb);
  10262. #endif
  10263. }
  10264. #if PY_MAJOR_VERSION < 3
  10265. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
  10266. CYTHON_UNUSED PyObject *cause) {
  10267. Py_XINCREF(type);
  10268. if (!value || value == Py_None)
  10269. value = NULL;
  10270. else
  10271. Py_INCREF(value);
  10272. if (!tb || tb == Py_None)
  10273. tb = NULL;
  10274. else {
  10275. Py_INCREF(tb);
  10276. if (!PyTraceBack_Check(tb)) {
  10277. PyErr_SetString(PyExc_TypeError,
  10278. "raise: arg 3 must be a traceback or None");
  10279. goto raise_error;
  10280. }
  10281. }
  10282. #if PY_VERSION_HEX < 0x02050000
  10283. if (PyClass_Check(type)) {
  10284. #else
  10285. if (PyType_Check(type)) {
  10286. #endif
  10287. #if CYTHON_COMPILING_IN_PYPY
  10288. if (!value) {
  10289. Py_INCREF(Py_None);
  10290. value = Py_None;
  10291. }
  10292. #endif
  10293. PyErr_NormalizeException(&type, &value, &tb);
  10294. } else {
  10295. if (value) {
  10296. PyErr_SetString(PyExc_TypeError,
  10297. "instance exception may not have a separate value");
  10298. goto raise_error;
  10299. }
  10300. value = type;
  10301. #if PY_VERSION_HEX < 0x02050000
  10302. if (PyInstance_Check(type)) {
  10303. type = (PyObject*) ((PyInstanceObject*)type)->in_class;
  10304. Py_INCREF(type);
  10305. } else {
  10306. type = 0;
  10307. PyErr_SetString(PyExc_TypeError,
  10308. "raise: exception must be an old-style class or instance");
  10309. goto raise_error;
  10310. }
  10311. #else
  10312. type = (PyObject*) Py_TYPE(type);
  10313. Py_INCREF(type);
  10314. if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
  10315. PyErr_SetString(PyExc_TypeError,
  10316. "raise: exception class must be a subclass of BaseException");
  10317. goto raise_error;
  10318. }
  10319. #endif
  10320. }
  10321. __Pyx_ErrRestore(type, value, tb);
  10322. return;
  10323. raise_error:
  10324. Py_XDECREF(value);
  10325. Py_XDECREF(type);
  10326. Py_XDECREF(tb);
  10327. return;
  10328. }
  10329. #else /* Python 3+ */
  10330. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
  10331. PyObject* owned_instance = NULL;
  10332. if (tb == Py_None) {
  10333. tb = 0;
  10334. } else if (tb && !PyTraceBack_Check(tb)) {
  10335. PyErr_SetString(PyExc_TypeError,
  10336. "raise: arg 3 must be a traceback or None");
  10337. goto bad;
  10338. }
  10339. if (value == Py_None)
  10340. value = 0;
  10341. if (PyExceptionInstance_Check(type)) {
  10342. if (value) {
  10343. PyErr_SetString(PyExc_TypeError,
  10344. "instance exception may not have a separate value");
  10345. goto bad;
  10346. }
  10347. value = type;
  10348. type = (PyObject*) Py_TYPE(value);
  10349. } else if (PyExceptionClass_Check(type)) {
  10350. PyObject *instance_class = NULL;
  10351. if (value && PyExceptionInstance_Check(value)) {
  10352. instance_class = (PyObject*) Py_TYPE(value);
  10353. if (instance_class != type) {
  10354. if (PyObject_IsSubclass(instance_class, type)) {
  10355. type = instance_class;
  10356. } else {
  10357. instance_class = NULL;
  10358. }
  10359. }
  10360. }
  10361. if (!instance_class) {
  10362. PyObject *args;
  10363. if (!value)
  10364. args = PyTuple_New(0);
  10365. else if (PyTuple_Check(value)) {
  10366. Py_INCREF(value);
  10367. args = value;
  10368. } else
  10369. args = PyTuple_Pack(1, value);
  10370. if (!args)
  10371. goto bad;
  10372. owned_instance = PyObject_Call(type, args, NULL);
  10373. Py_DECREF(args);
  10374. if (!owned_instance)
  10375. goto bad;
  10376. value = owned_instance;
  10377. if (!PyExceptionInstance_Check(value)) {
  10378. PyErr_Format(PyExc_TypeError,
  10379. "calling %R should have returned an instance of "
  10380. "BaseException, not %R",
  10381. type, Py_TYPE(value));
  10382. goto bad;
  10383. }
  10384. }
  10385. } else {
  10386. PyErr_SetString(PyExc_TypeError,
  10387. "raise: exception class must be a subclass of BaseException");
  10388. goto bad;
  10389. }
  10390. #if PY_VERSION_HEX >= 0x03030000
  10391. if (cause) {
  10392. #else
  10393. if (cause && cause != Py_None) {
  10394. #endif
  10395. PyObject *fixed_cause;
  10396. if (cause == Py_None) {
  10397. fixed_cause = NULL;
  10398. } else if (PyExceptionClass_Check(cause)) {
  10399. fixed_cause = PyObject_CallObject(cause, NULL);
  10400. if (fixed_cause == NULL)
  10401. goto bad;
  10402. } else if (PyExceptionInstance_Check(cause)) {
  10403. fixed_cause = cause;
  10404. Py_INCREF(fixed_cause);
  10405. } else {
  10406. PyErr_SetString(PyExc_TypeError,
  10407. "exception causes must derive from "
  10408. "BaseException");
  10409. goto bad;
  10410. }
  10411. PyException_SetCause(value, fixed_cause);
  10412. }
  10413. PyErr_SetObject(type, value);
  10414. if (tb) {
  10415. PyThreadState *tstate = PyThreadState_GET();
  10416. PyObject* tmp_tb = tstate->curexc_traceback;
  10417. if (tb != tmp_tb) {
  10418. Py_INCREF(tb);
  10419. tstate->curexc_traceback = tb;
  10420. Py_XDECREF(tmp_tb);
  10421. }
  10422. }
  10423. bad:
  10424. Py_XDECREF(owned_instance);
  10425. return;
  10426. }
  10427. #endif
  10428. static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
  10429. #if CYTHON_COMPILING_IN_CPYTHON
  10430. PyThreadState *tstate = PyThreadState_GET();
  10431. *type = tstate->exc_type;
  10432. *value = tstate->exc_value;
  10433. *tb = tstate->exc_traceback;
  10434. Py_XINCREF(*type);
  10435. Py_XINCREF(*value);
  10436. Py_XINCREF(*tb);
  10437. #else
  10438. PyErr_GetExcInfo(type, value, tb);
  10439. #endif
  10440. }
  10441. static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
  10442. #if CYTHON_COMPILING_IN_CPYTHON
  10443. PyObject *tmp_type, *tmp_value, *tmp_tb;
  10444. PyThreadState *tstate = PyThreadState_GET();
  10445. tmp_type = tstate->exc_type;
  10446. tmp_value = tstate->exc_value;
  10447. tmp_tb = tstate->exc_traceback;
  10448. tstate->exc_type = type;
  10449. tstate->exc_value = value;
  10450. tstate->exc_traceback = tb;
  10451. Py_XDECREF(tmp_type);
  10452. Py_XDECREF(tmp_value);
  10453. Py_XDECREF(tmp_tb);
  10454. #else
  10455. PyErr_SetExcInfo(type, value, tb);
  10456. #endif
  10457. }
  10458. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
  10459. PyObject *local_type, *local_value, *local_tb;
  10460. #if CYTHON_COMPILING_IN_CPYTHON
  10461. PyObject *tmp_type, *tmp_value, *tmp_tb;
  10462. PyThreadState *tstate = PyThreadState_GET();
  10463. local_type = tstate->curexc_type;
  10464. local_value = tstate->curexc_value;
  10465. local_tb = tstate->curexc_traceback;
  10466. tstate->curexc_type = 0;
  10467. tstate->curexc_value = 0;
  10468. tstate->curexc_traceback = 0;
  10469. #else
  10470. PyErr_Fetch(&local_type, &local_value, &local_tb);
  10471. #endif
  10472. PyErr_NormalizeException(&local_type, &local_value, &local_tb);
  10473. #if CYTHON_COMPILING_IN_CPYTHON
  10474. if (unlikely(tstate->curexc_type))
  10475. #else
  10476. if (unlikely(PyErr_Occurred()))
  10477. #endif
  10478. goto bad;
  10479. #if PY_MAJOR_VERSION >= 3
  10480. if (local_tb) {
  10481. if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
  10482. goto bad;
  10483. }
  10484. #endif
  10485. Py_XINCREF(local_tb);
  10486. Py_XINCREF(local_type);
  10487. Py_XINCREF(local_value);
  10488. *type = local_type;
  10489. *value = local_value;
  10490. *tb = local_tb;
  10491. #if CYTHON_COMPILING_IN_CPYTHON
  10492. tmp_type = tstate->exc_type;
  10493. tmp_value = tstate->exc_value;
  10494. tmp_tb = tstate->exc_traceback;
  10495. tstate->exc_type = local_type;
  10496. tstate->exc_value = local_value;
  10497. tstate->exc_traceback = local_tb;
  10498. Py_XDECREF(tmp_type);
  10499. Py_XDECREF(tmp_value);
  10500. Py_XDECREF(tmp_tb);
  10501. #else
  10502. PyErr_SetExcInfo(local_type, local_value, local_tb);
  10503. #endif
  10504. return 0;
  10505. bad:
  10506. *type = 0;
  10507. *value = 0;
  10508. *tb = 0;
  10509. Py_XDECREF(local_type);
  10510. Py_XDECREF(local_value);
  10511. Py_XDECREF(local_tb);
  10512. return -1;
  10513. }
  10514. static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
  10515. PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
  10516. }
  10517. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
  10518. #if CYTHON_COMPILING_IN_PYPY
  10519. return PyObject_RichCompareBool(s1, s2, equals);
  10520. #else
  10521. if (s1 == s2) {
  10522. return (equals == Py_EQ);
  10523. } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
  10524. const char *ps1, *ps2;
  10525. Py_ssize_t length = PyBytes_GET_SIZE(s1);
  10526. if (length != PyBytes_GET_SIZE(s2))
  10527. return (equals == Py_NE);
  10528. ps1 = PyBytes_AS_STRING(s1);
  10529. ps2 = PyBytes_AS_STRING(s2);
  10530. if (ps1[0] != ps2[0]) {
  10531. return (equals == Py_NE);
  10532. } else if (length == 1) {
  10533. return (equals == Py_EQ);
  10534. } else {
  10535. int result = memcmp(ps1, ps2, (size_t)length);
  10536. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  10537. }
  10538. } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
  10539. return (equals == Py_NE);
  10540. } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
  10541. return (equals == Py_NE);
  10542. } else {
  10543. int result;
  10544. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  10545. if (!py_result)
  10546. return -1;
  10547. result = __Pyx_PyObject_IsTrue(py_result);
  10548. Py_DECREF(py_result);
  10549. return result;
  10550. }
  10551. #endif
  10552. }
  10553. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
  10554. #if CYTHON_COMPILING_IN_PYPY
  10555. return PyObject_RichCompareBool(s1, s2, equals);
  10556. #else
  10557. #if PY_MAJOR_VERSION < 3
  10558. PyObject* owned_ref = NULL;
  10559. #endif
  10560. int s1_is_unicode, s2_is_unicode;
  10561. if (s1 == s2) {
  10562. goto return_eq;
  10563. }
  10564. s1_is_unicode = PyUnicode_CheckExact(s1);
  10565. s2_is_unicode = PyUnicode_CheckExact(s2);
  10566. #if PY_MAJOR_VERSION < 3
  10567. if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
  10568. owned_ref = PyUnicode_FromObject(s2);
  10569. if (unlikely(!owned_ref))
  10570. return -1;
  10571. s2 = owned_ref;
  10572. s2_is_unicode = 1;
  10573. } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
  10574. owned_ref = PyUnicode_FromObject(s1);
  10575. if (unlikely(!owned_ref))
  10576. return -1;
  10577. s1 = owned_ref;
  10578. s1_is_unicode = 1;
  10579. } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
  10580. return __Pyx_PyBytes_Equals(s1, s2, equals);
  10581. }
  10582. #endif
  10583. if (s1_is_unicode & s2_is_unicode) {
  10584. Py_ssize_t length;
  10585. int kind;
  10586. void *data1, *data2;
  10587. #if CYTHON_PEP393_ENABLED
  10588. if (unlikely(PyUnicode_READY(s1) < 0) || unlikely(PyUnicode_READY(s2) < 0))
  10589. return -1;
  10590. #endif
  10591. length = __Pyx_PyUnicode_GET_LENGTH(s1);
  10592. if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
  10593. goto return_ne;
  10594. }
  10595. kind = __Pyx_PyUnicode_KIND(s1);
  10596. if (kind != __Pyx_PyUnicode_KIND(s2)) {
  10597. goto return_ne;
  10598. }
  10599. data1 = __Pyx_PyUnicode_DATA(s1);
  10600. data2 = __Pyx_PyUnicode_DATA(s2);
  10601. if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
  10602. goto return_ne;
  10603. } else if (length == 1) {
  10604. goto return_eq;
  10605. } else {
  10606. int result = memcmp(data1, data2, length * kind);
  10607. #if PY_MAJOR_VERSION < 3
  10608. Py_XDECREF(owned_ref);
  10609. #endif
  10610. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  10611. }
  10612. } else if ((s1 == Py_None) & s2_is_unicode) {
  10613. goto return_ne;
  10614. } else if ((s2 == Py_None) & s1_is_unicode) {
  10615. goto return_ne;
  10616. } else {
  10617. int result;
  10618. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  10619. if (!py_result)
  10620. return -1;
  10621. result = __Pyx_PyObject_IsTrue(py_result);
  10622. Py_DECREF(py_result);
  10623. return result;
  10624. }
  10625. return_eq:
  10626. #if PY_MAJOR_VERSION < 3
  10627. Py_XDECREF(owned_ref);
  10628. #endif
  10629. return (equals == Py_EQ);
  10630. return_ne:
  10631. #if PY_MAJOR_VERSION < 3
  10632. Py_XDECREF(owned_ref);
  10633. #endif
  10634. return (equals == Py_NE);
  10635. #endif
  10636. }
  10637. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
  10638. PyObject *tmp_type, *tmp_value, *tmp_tb;
  10639. #if CYTHON_COMPILING_IN_CPYTHON
  10640. PyThreadState *tstate = PyThreadState_GET();
  10641. tmp_type = tstate->exc_type;
  10642. tmp_value = tstate->exc_value;
  10643. tmp_tb = tstate->exc_traceback;
  10644. tstate->exc_type = *type;
  10645. tstate->exc_value = *value;
  10646. tstate->exc_traceback = *tb;
  10647. #else
  10648. PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
  10649. PyErr_SetExcInfo(*type, *value, *tb);
  10650. #endif
  10651. *type = tmp_type;
  10652. *value = tmp_value;
  10653. *tb = tmp_tb;
  10654. }
  10655. static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
  10656. PyObject* fake_module;
  10657. PyTypeObject* cached_type = NULL;
  10658. fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
  10659. if (!fake_module) return NULL;
  10660. Py_INCREF(fake_module);
  10661. cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
  10662. if (cached_type) {
  10663. if (!PyType_Check((PyObject*)cached_type)) {
  10664. PyErr_Format(PyExc_TypeError,
  10665. "Shared Cython type %.200s is not a type object",
  10666. type->tp_name);
  10667. goto bad;
  10668. }
  10669. if (cached_type->tp_basicsize != type->tp_basicsize) {
  10670. PyErr_Format(PyExc_TypeError,
  10671. "Shared Cython type %.200s has the wrong size, try recompiling",
  10672. type->tp_name);
  10673. goto bad;
  10674. }
  10675. } else {
  10676. if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
  10677. PyErr_Clear();
  10678. if (PyType_Ready(type) < 0) goto bad;
  10679. if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
  10680. goto bad;
  10681. Py_INCREF(type);
  10682. cached_type = type;
  10683. }
  10684. done:
  10685. Py_DECREF(fake_module);
  10686. return cached_type;
  10687. bad:
  10688. Py_XDECREF(cached_type);
  10689. cached_type = NULL;
  10690. goto done;
  10691. }
  10692. static PyObject *
  10693. __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
  10694. {
  10695. if (unlikely(op->func_doc == NULL)) {
  10696. if (op->func.m_ml->ml_doc) {
  10697. #if PY_MAJOR_VERSION >= 3
  10698. op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
  10699. #else
  10700. op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
  10701. #endif
  10702. if (unlikely(op->func_doc == NULL))
  10703. return NULL;
  10704. } else {
  10705. Py_INCREF(Py_None);
  10706. return Py_None;
  10707. }
  10708. }
  10709. Py_INCREF(op->func_doc);
  10710. return op->func_doc;
  10711. }
  10712. static int
  10713. __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
  10714. {
  10715. PyObject *tmp = op->func_doc;
  10716. if (value == NULL)
  10717. value = Py_None; /* Mark as deleted */
  10718. Py_INCREF(value);
  10719. op->func_doc = value;
  10720. Py_XDECREF(tmp);
  10721. return 0;
  10722. }
  10723. static PyObject *
  10724. __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
  10725. {
  10726. if (unlikely(op->func_name == NULL)) {
  10727. #if PY_MAJOR_VERSION >= 3
  10728. op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
  10729. #else
  10730. op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
  10731. #endif
  10732. if (unlikely(op->func_name == NULL))
  10733. return NULL;
  10734. }
  10735. Py_INCREF(op->func_name);
  10736. return op->func_name;
  10737. }
  10738. static int
  10739. __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
  10740. {
  10741. PyObject *tmp;
  10742. #if PY_MAJOR_VERSION >= 3
  10743. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  10744. #else
  10745. if (unlikely(value == NULL || !PyString_Check(value))) {
  10746. #endif
  10747. PyErr_SetString(PyExc_TypeError,
  10748. "__name__ must be set to a string object");
  10749. return -1;
  10750. }
  10751. tmp = op->func_name;
  10752. Py_INCREF(value);
  10753. op->func_name = value;
  10754. Py_XDECREF(tmp);
  10755. return 0;
  10756. }
  10757. static PyObject *
  10758. __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
  10759. {
  10760. Py_INCREF(op->func_qualname);
  10761. return op->func_qualname;
  10762. }
  10763. static int
  10764. __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
  10765. {
  10766. PyObject *tmp;
  10767. #if PY_MAJOR_VERSION >= 3
  10768. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  10769. #else
  10770. if (unlikely(value == NULL || !PyString_Check(value))) {
  10771. #endif
  10772. PyErr_SetString(PyExc_TypeError,
  10773. "__qualname__ must be set to a string object");
  10774. return -1;
  10775. }
  10776. tmp = op->func_qualname;
  10777. Py_INCREF(value);
  10778. op->func_qualname = value;
  10779. Py_XDECREF(tmp);
  10780. return 0;
  10781. }
  10782. static PyObject *
  10783. __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
  10784. {
  10785. PyObject *self;
  10786. self = m->func_closure;
  10787. if (self == NULL)
  10788. self = Py_None;
  10789. Py_INCREF(self);
  10790. return self;
  10791. }
  10792. static PyObject *
  10793. __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
  10794. {
  10795. if (unlikely(op->func_dict == NULL)) {
  10796. op->func_dict = PyDict_New();
  10797. if (unlikely(op->func_dict == NULL))
  10798. return NULL;
  10799. }
  10800. Py_INCREF(op->func_dict);
  10801. return op->func_dict;
  10802. }
  10803. static int
  10804. __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
  10805. {
  10806. PyObject *tmp;
  10807. if (unlikely(value == NULL)) {
  10808. PyErr_SetString(PyExc_TypeError,
  10809. "function's dictionary may not be deleted");
  10810. return -1;
  10811. }
  10812. if (unlikely(!PyDict_Check(value))) {
  10813. PyErr_SetString(PyExc_TypeError,
  10814. "setting function's dictionary to a non-dict");
  10815. return -1;
  10816. }
  10817. tmp = op->func_dict;
  10818. Py_INCREF(value);
  10819. op->func_dict = value;
  10820. Py_XDECREF(tmp);
  10821. return 0;
  10822. }
  10823. static PyObject *
  10824. __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
  10825. {
  10826. Py_INCREF(op->func_globals);
  10827. return op->func_globals;
  10828. }
  10829. static PyObject *
  10830. __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
  10831. {
  10832. Py_INCREF(Py_None);
  10833. return Py_None;
  10834. }
  10835. static PyObject *
  10836. __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
  10837. {
  10838. PyObject* result = (op->func_code) ? op->func_code : Py_None;
  10839. Py_INCREF(result);
  10840. return result;
  10841. }
  10842. static int
  10843. __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
  10844. PyObject *res = op->defaults_getter((PyObject *) op);
  10845. if (unlikely(!res))
  10846. return -1;
  10847. op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
  10848. Py_INCREF(op->defaults_tuple);
  10849. op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
  10850. Py_INCREF(op->defaults_kwdict);
  10851. Py_DECREF(res);
  10852. return 0;
  10853. }
  10854. static int
  10855. __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
  10856. PyObject* tmp;
  10857. if (!value) {
  10858. value = Py_None;
  10859. } else if (value != Py_None && !PyTuple_Check(value)) {
  10860. PyErr_SetString(PyExc_TypeError,
  10861. "__defaults__ must be set to a tuple object");
  10862. return -1;
  10863. }
  10864. Py_INCREF(value);
  10865. tmp = op->defaults_tuple;
  10866. op->defaults_tuple = value;
  10867. Py_XDECREF(tmp);
  10868. return 0;
  10869. }
  10870. static PyObject *
  10871. __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
  10872. PyObject* result = op->defaults_tuple;
  10873. if (unlikely(!result)) {
  10874. if (op->defaults_getter) {
  10875. if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
  10876. result = op->defaults_tuple;
  10877. } else {
  10878. result = Py_None;
  10879. }
  10880. }
  10881. Py_INCREF(result);
  10882. return result;
  10883. }
  10884. static int
  10885. __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
  10886. PyObject* tmp;
  10887. if (!value) {
  10888. value = Py_None;
  10889. } else if (value != Py_None && !PyDict_Check(value)) {
  10890. PyErr_SetString(PyExc_TypeError,
  10891. "__kwdefaults__ must be set to a dict object");
  10892. return -1;
  10893. }
  10894. Py_INCREF(value);
  10895. tmp = op->defaults_kwdict;
  10896. op->defaults_kwdict = value;
  10897. Py_XDECREF(tmp);
  10898. return 0;
  10899. }
  10900. static PyObject *
  10901. __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
  10902. PyObject* result = op->defaults_kwdict;
  10903. if (unlikely(!result)) {
  10904. if (op->defaults_getter) {
  10905. if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
  10906. result = op->defaults_kwdict;
  10907. } else {
  10908. result = Py_None;
  10909. }
  10910. }
  10911. Py_INCREF(result);
  10912. return result;
  10913. }
  10914. static int
  10915. __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
  10916. PyObject* tmp;
  10917. if (!value || value == Py_None) {
  10918. value = NULL;
  10919. } else if (!PyDict_Check(value)) {
  10920. PyErr_SetString(PyExc_TypeError,
  10921. "__annotations__ must be set to a dict object");
  10922. return -1;
  10923. }
  10924. Py_XINCREF(value);
  10925. tmp = op->func_annotations;
  10926. op->func_annotations = value;
  10927. Py_XDECREF(tmp);
  10928. return 0;
  10929. }
  10930. static PyObject *
  10931. __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
  10932. PyObject* result = op->func_annotations;
  10933. if (unlikely(!result)) {
  10934. result = PyDict_New();
  10935. if (unlikely(!result)) return NULL;
  10936. op->func_annotations = result;
  10937. }
  10938. Py_INCREF(result);
  10939. return result;
  10940. }
  10941. static PyGetSetDef __pyx_CyFunction_getsets[] = {
  10942. {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
  10943. {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
  10944. {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
  10945. {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
  10946. {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
  10947. {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
  10948. {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
  10949. {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
  10950. {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
  10951. {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
  10952. {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
  10953. {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
  10954. {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
  10955. {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
  10956. {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
  10957. {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
  10958. {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
  10959. {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
  10960. {0, 0, 0, 0, 0}
  10961. };
  10962. #ifndef PY_WRITE_RESTRICTED /* < Py2.5 */
  10963. #define PY_WRITE_RESTRICTED WRITE_RESTRICTED
  10964. #endif
  10965. static PyMemberDef __pyx_CyFunction_members[] = {
  10966. {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0},
  10967. {0, 0, 0, 0, 0}
  10968. };
  10969. static PyObject *
  10970. __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
  10971. {
  10972. #if PY_MAJOR_VERSION >= 3
  10973. return PyUnicode_FromString(m->func.m_ml->ml_name);
  10974. #else
  10975. return PyString_FromString(m->func.m_ml->ml_name);
  10976. #endif
  10977. }
  10978. static PyMethodDef __pyx_CyFunction_methods[] = {
  10979. {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
  10980. {0, 0, 0, 0}
  10981. };
  10982. static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
  10983. PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
  10984. __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
  10985. if (op == NULL)
  10986. return NULL;
  10987. op->flags = flags;
  10988. op->func_weakreflist = NULL;
  10989. op->func.m_ml = ml;
  10990. op->func.m_self = (PyObject *) op;
  10991. Py_XINCREF(closure);
  10992. op->func_closure = closure;
  10993. Py_XINCREF(module);
  10994. op->func.m_module = module;
  10995. op->func_dict = NULL;
  10996. op->func_name = NULL;
  10997. Py_INCREF(qualname);
  10998. op->func_qualname = qualname;
  10999. op->func_doc = NULL;
  11000. op->func_classobj = NULL;
  11001. op->func_globals = globals;
  11002. Py_INCREF(op->func_globals);
  11003. Py_XINCREF(code);
  11004. op->func_code = code;
  11005. op->defaults_pyobjects = 0;
  11006. op->defaults = NULL;
  11007. op->defaults_tuple = NULL;
  11008. op->defaults_kwdict = NULL;
  11009. op->defaults_getter = NULL;
  11010. op->func_annotations = NULL;
  11011. PyObject_GC_Track(op);
  11012. return (PyObject *) op;
  11013. }
  11014. static int
  11015. __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
  11016. {
  11017. Py_CLEAR(m->func_closure);
  11018. Py_CLEAR(m->func.m_module);
  11019. Py_CLEAR(m->func_dict);
  11020. Py_CLEAR(m->func_name);
  11021. Py_CLEAR(m->func_qualname);
  11022. Py_CLEAR(m->func_doc);
  11023. Py_CLEAR(m->func_globals);
  11024. Py_CLEAR(m->func_code);
  11025. Py_CLEAR(m->func_classobj);
  11026. Py_CLEAR(m->defaults_tuple);
  11027. Py_CLEAR(m->defaults_kwdict);
  11028. Py_CLEAR(m->func_annotations);
  11029. if (m->defaults) {
  11030. PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
  11031. int i;
  11032. for (i = 0; i < m->defaults_pyobjects; i++)
  11033. Py_XDECREF(pydefaults[i]);
  11034. PyMem_Free(m->defaults);
  11035. m->defaults = NULL;
  11036. }
  11037. return 0;
  11038. }
  11039. static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
  11040. {
  11041. PyObject_GC_UnTrack(m);
  11042. if (m->func_weakreflist != NULL)
  11043. PyObject_ClearWeakRefs((PyObject *) m);
  11044. __Pyx_CyFunction_clear(m);
  11045. PyObject_GC_Del(m);
  11046. }
  11047. static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
  11048. {
  11049. Py_VISIT(m->func_closure);
  11050. Py_VISIT(m->func.m_module);
  11051. Py_VISIT(m->func_dict);
  11052. Py_VISIT(m->func_name);
  11053. Py_VISIT(m->func_qualname);
  11054. Py_VISIT(m->func_doc);
  11055. Py_VISIT(m->func_globals);
  11056. Py_VISIT(m->func_code);
  11057. Py_VISIT(m->func_classobj);
  11058. Py_VISIT(m->defaults_tuple);
  11059. Py_VISIT(m->defaults_kwdict);
  11060. if (m->defaults) {
  11061. PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
  11062. int i;
  11063. for (i = 0; i < m->defaults_pyobjects; i++)
  11064. Py_VISIT(pydefaults[i]);
  11065. }
  11066. return 0;
  11067. }
  11068. static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
  11069. {
  11070. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  11071. if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
  11072. Py_INCREF(func);
  11073. return func;
  11074. }
  11075. if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
  11076. if (type == NULL)
  11077. type = (PyObject *)(Py_TYPE(obj));
  11078. return PyMethod_New(func,
  11079. type, (PyObject *)(Py_TYPE(type)));
  11080. }
  11081. if (obj == Py_None)
  11082. obj = NULL;
  11083. return PyMethod_New(func, obj, type);
  11084. }
  11085. static PyObject*
  11086. __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
  11087. {
  11088. #if PY_MAJOR_VERSION >= 3
  11089. return PyUnicode_FromFormat("<cyfunction %U at %p>",
  11090. op->func_qualname, (void *)op);
  11091. #else
  11092. return PyString_FromFormat("<cyfunction %s at %p>",
  11093. PyString_AsString(op->func_qualname), (void *)op);
  11094. #endif
  11095. }
  11096. #if CYTHON_COMPILING_IN_PYPY
  11097. static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  11098. PyCFunctionObject* f = (PyCFunctionObject*)func;
  11099. PyCFunction meth = PyCFunction_GET_FUNCTION(func);
  11100. PyObject *self = PyCFunction_GET_SELF(func);
  11101. Py_ssize_t size;
  11102. switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) {
  11103. case METH_VARARGS:
  11104. if (likely(kw == NULL) || PyDict_Size(kw) == 0)
  11105. return (*meth)(self, arg);
  11106. break;
  11107. case METH_VARARGS | METH_KEYWORDS:
  11108. return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
  11109. case METH_NOARGS:
  11110. if (likely(kw == NULL) || PyDict_Size(kw) == 0) {
  11111. size = PyTuple_GET_SIZE(arg);
  11112. if (size == 0)
  11113. return (*meth)(self, NULL);
  11114. PyErr_Format(PyExc_TypeError,
  11115. "%.200s() takes no arguments (%zd given)",
  11116. f->m_ml->ml_name, size);
  11117. return NULL;
  11118. }
  11119. break;
  11120. case METH_O:
  11121. if (likely(kw == NULL) || PyDict_Size(kw) == 0) {
  11122. size = PyTuple_GET_SIZE(arg);
  11123. if (size == 1)
  11124. return (*meth)(self, PyTuple_GET_ITEM(arg, 0));
  11125. PyErr_Format(PyExc_TypeError,
  11126. "%.200s() takes exactly one argument (%zd given)",
  11127. f->m_ml->ml_name, size);
  11128. return NULL;
  11129. }
  11130. break;
  11131. default:
  11132. PyErr_SetString(PyExc_SystemError, "Bad call flags in "
  11133. "__Pyx_CyFunction_Call. METH_OLDARGS is no "
  11134. "longer supported!");
  11135. return NULL;
  11136. }
  11137. PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
  11138. f->m_ml->ml_name);
  11139. return NULL;
  11140. }
  11141. #else
  11142. static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  11143. return PyCFunction_Call(func, arg, kw);
  11144. }
  11145. #endif
  11146. static PyTypeObject __pyx_CyFunctionType_type = {
  11147. PyVarObject_HEAD_INIT(0, 0)
  11148. __Pyx_NAMESTR("cython_function_or_method"), /*tp_name*/
  11149. sizeof(__pyx_CyFunctionObject), /*tp_basicsize*/
  11150. 0, /*tp_itemsize*/
  11151. (destructor) __Pyx_CyFunction_dealloc, /*tp_dealloc*/
  11152. 0, /*tp_print*/
  11153. 0, /*tp_getattr*/
  11154. 0, /*tp_setattr*/
  11155. #if PY_MAJOR_VERSION < 3
  11156. 0, /*tp_compare*/
  11157. #else
  11158. 0, /*reserved*/
  11159. #endif
  11160. (reprfunc) __Pyx_CyFunction_repr, /*tp_repr*/
  11161. 0, /*tp_as_number*/
  11162. 0, /*tp_as_sequence*/
  11163. 0, /*tp_as_mapping*/
  11164. 0, /*tp_hash*/
  11165. __Pyx_CyFunction_Call, /*tp_call*/
  11166. 0, /*tp_str*/
  11167. 0, /*tp_getattro*/
  11168. 0, /*tp_setattro*/
  11169. 0, /*tp_as_buffer*/
  11170. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags*/
  11171. 0, /*tp_doc*/
  11172. (traverseproc) __Pyx_CyFunction_traverse, /*tp_traverse*/
  11173. (inquiry) __Pyx_CyFunction_clear, /*tp_clear*/
  11174. 0, /*tp_richcompare*/
  11175. offsetof(__pyx_CyFunctionObject, func_weakreflist), /* tp_weaklistoffse */
  11176. 0, /*tp_iter*/
  11177. 0, /*tp_iternext*/
  11178. __pyx_CyFunction_methods, /*tp_methods*/
  11179. __pyx_CyFunction_members, /*tp_members*/
  11180. __pyx_CyFunction_getsets, /*tp_getset*/
  11181. 0, /*tp_base*/
  11182. 0, /*tp_dict*/
  11183. __Pyx_CyFunction_descr_get, /*tp_descr_get*/
  11184. 0, /*tp_descr_set*/
  11185. offsetof(__pyx_CyFunctionObject, func_dict),/*tp_dictoffset*/
  11186. 0, /*tp_init*/
  11187. 0, /*tp_alloc*/
  11188. 0, /*tp_new*/
  11189. 0, /*tp_free*/
  11190. 0, /*tp_is_gc*/
  11191. 0, /*tp_bases*/
  11192. 0, /*tp_mro*/
  11193. 0, /*tp_cache*/
  11194. 0, /*tp_subclasses*/
  11195. 0, /*tp_weaklist*/
  11196. 0, /*tp_del*/
  11197. #if PY_VERSION_HEX >= 0x02060000
  11198. 0, /*tp_version_tag*/
  11199. #endif
  11200. #if PY_VERSION_HEX >= 0x030400a1
  11201. 0, /*tp_finalize*/
  11202. #endif
  11203. };
  11204. static int __Pyx_CyFunction_init(void) {
  11205. #if !CYTHON_COMPILING_IN_PYPY
  11206. __pyx_CyFunctionType_type.tp_call = PyCFunction_Call;
  11207. #endif
  11208. __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
  11209. if (__pyx_CyFunctionType == NULL) {
  11210. return -1;
  11211. }
  11212. return 0;
  11213. }
  11214. static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
  11215. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  11216. m->defaults = PyMem_Malloc(size);
  11217. if (!m->defaults)
  11218. return PyErr_NoMemory();
  11219. memset(m->defaults, 0, size);
  11220. m->defaults_pyobjects = pyobjects;
  11221. return m->defaults;
  11222. }
  11223. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
  11224. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  11225. m->defaults_tuple = tuple;
  11226. Py_INCREF(tuple);
  11227. }
  11228. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
  11229. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  11230. m->defaults_kwdict = dict;
  11231. Py_INCREF(dict);
  11232. }
  11233. static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
  11234. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  11235. m->func_annotations = dict;
  11236. Py_INCREF(dict);
  11237. }
  11238. static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
  11239. Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
  11240. for (i=0; i < nbases; i++) {
  11241. PyTypeObject *tmptype;
  11242. PyObject *tmp = PyTuple_GET_ITEM(bases, i);
  11243. tmptype = Py_TYPE(tmp);
  11244. #if PY_MAJOR_VERSION < 3
  11245. if (tmptype == &PyClass_Type)
  11246. continue;
  11247. #endif
  11248. if (!metaclass) {
  11249. metaclass = tmptype;
  11250. continue;
  11251. }
  11252. if (PyType_IsSubtype(metaclass, tmptype))
  11253. continue;
  11254. if (PyType_IsSubtype(tmptype, metaclass)) {
  11255. metaclass = tmptype;
  11256. continue;
  11257. }
  11258. PyErr_SetString(PyExc_TypeError,
  11259. "metaclass conflict: "
  11260. "the metaclass of a derived class "
  11261. "must be a (non-strict) subclass "
  11262. "of the metaclasses of all its bases");
  11263. return NULL;
  11264. }
  11265. if (!metaclass) {
  11266. #if PY_MAJOR_VERSION < 3
  11267. metaclass = &PyClass_Type;
  11268. #else
  11269. metaclass = &PyType_Type;
  11270. #endif
  11271. }
  11272. Py_INCREF((PyObject*) metaclass);
  11273. return (PyObject*) metaclass;
  11274. }
  11275. static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
  11276. PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
  11277. PyObject *ns;
  11278. if (metaclass) {
  11279. PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
  11280. if (prep) {
  11281. PyObject *pargs = PyTuple_Pack(2, name, bases);
  11282. if (unlikely(!pargs)) {
  11283. Py_DECREF(prep);
  11284. return NULL;
  11285. }
  11286. ns = PyObject_Call(prep, pargs, mkw);
  11287. Py_DECREF(prep);
  11288. Py_DECREF(pargs);
  11289. } else {
  11290. if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
  11291. return NULL;
  11292. PyErr_Clear();
  11293. ns = PyDict_New();
  11294. }
  11295. } else {
  11296. ns = PyDict_New();
  11297. }
  11298. if (unlikely(!ns))
  11299. return NULL;
  11300. if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
  11301. if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
  11302. if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
  11303. return ns;
  11304. bad:
  11305. Py_DECREF(ns);
  11306. return NULL;
  11307. }
  11308. static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
  11309. PyObject *dict, PyObject *mkw,
  11310. int calculate_metaclass, int allow_py2_metaclass) {
  11311. PyObject *result, *margs;
  11312. PyObject *owned_metaclass = NULL;
  11313. if (allow_py2_metaclass) {
  11314. owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
  11315. if (owned_metaclass) {
  11316. metaclass = owned_metaclass;
  11317. } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
  11318. PyErr_Clear();
  11319. } else {
  11320. return NULL;
  11321. }
  11322. }
  11323. if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
  11324. metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
  11325. Py_XDECREF(owned_metaclass);
  11326. if (unlikely(!metaclass))
  11327. return NULL;
  11328. owned_metaclass = metaclass;
  11329. }
  11330. margs = PyTuple_Pack(3, name, bases, dict);
  11331. if (unlikely(!margs)) {
  11332. result = NULL;
  11333. } else {
  11334. result = PyObject_Call(metaclass, margs, mkw);
  11335. Py_DECREF(margs);
  11336. }
  11337. Py_XDECREF(owned_metaclass);
  11338. return result;
  11339. }
  11340. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
  11341. PyObject *empty_list = 0;
  11342. PyObject *module = 0;
  11343. PyObject *global_dict = 0;
  11344. PyObject *empty_dict = 0;
  11345. PyObject *list;
  11346. #if PY_VERSION_HEX < 0x03030000
  11347. PyObject *py_import;
  11348. py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
  11349. if (!py_import)
  11350. goto bad;
  11351. #endif
  11352. if (from_list)
  11353. list = from_list;
  11354. else {
  11355. empty_list = PyList_New(0);
  11356. if (!empty_list)
  11357. goto bad;
  11358. list = empty_list;
  11359. }
  11360. global_dict = PyModule_GetDict(__pyx_m);
  11361. if (!global_dict)
  11362. goto bad;
  11363. empty_dict = PyDict_New();
  11364. if (!empty_dict)
  11365. goto bad;
  11366. #if PY_VERSION_HEX >= 0x02050000
  11367. {
  11368. #if PY_MAJOR_VERSION >= 3
  11369. if (level == -1) {
  11370. if (strchr(__Pyx_MODULE_NAME, '.')) {
  11371. #if PY_VERSION_HEX < 0x03030000
  11372. PyObject *py_level = PyInt_FromLong(1);
  11373. if (!py_level)
  11374. goto bad;
  11375. module = PyObject_CallFunctionObjArgs(py_import,
  11376. name, global_dict, empty_dict, list, py_level, NULL);
  11377. Py_DECREF(py_level);
  11378. #else
  11379. module = PyImport_ImportModuleLevelObject(
  11380. name, global_dict, empty_dict, list, 1);
  11381. #endif
  11382. if (!module) {
  11383. if (!PyErr_ExceptionMatches(PyExc_ImportError))
  11384. goto bad;
  11385. PyErr_Clear();
  11386. }
  11387. }
  11388. level = 0; /* try absolute import on failure */
  11389. }
  11390. #endif
  11391. if (!module) {
  11392. #if PY_VERSION_HEX < 0x03030000
  11393. PyObject *py_level = PyInt_FromLong(level);
  11394. if (!py_level)
  11395. goto bad;
  11396. module = PyObject_CallFunctionObjArgs(py_import,
  11397. name, global_dict, empty_dict, list, py_level, NULL);
  11398. Py_DECREF(py_level);
  11399. #else
  11400. module = PyImport_ImportModuleLevelObject(
  11401. name, global_dict, empty_dict, list, level);
  11402. #endif
  11403. }
  11404. }
  11405. #else
  11406. if (level>0) {
  11407. PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
  11408. goto bad;
  11409. }
  11410. module = PyObject_CallFunctionObjArgs(py_import,
  11411. name, global_dict, empty_dict, list, NULL);
  11412. #endif
  11413. bad:
  11414. #if PY_VERSION_HEX < 0x03030000
  11415. Py_XDECREF(py_import);
  11416. #endif
  11417. Py_XDECREF(empty_list);
  11418. Py_XDECREF(empty_dict);
  11419. return module;
  11420. }
  11421. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
  11422. const long neg_one = (long) -1, const_zero = 0;
  11423. const int is_unsigned = neg_one > const_zero;
  11424. if (is_unsigned) {
  11425. if (sizeof(long) < sizeof(long)) {
  11426. return PyInt_FromLong((long) value);
  11427. } else if (sizeof(long) <= sizeof(unsigned long)) {
  11428. return PyLong_FromUnsignedLong((unsigned long) value);
  11429. } else if (sizeof(long) <= sizeof(unsigned long long)) {
  11430. return PyLong_FromUnsignedLongLong((unsigned long long) value);
  11431. }
  11432. } else {
  11433. if (sizeof(long) <= sizeof(long)) {
  11434. return PyInt_FromLong((long) value);
  11435. } else if (sizeof(long) <= sizeof(long long)) {
  11436. return PyLong_FromLongLong((long long) value);
  11437. }
  11438. }
  11439. {
  11440. int one = 1; int little = (int)*(unsigned char *)&one;
  11441. unsigned char *bytes = (unsigned char *)&value;
  11442. return _PyLong_FromByteArray(bytes, sizeof(long),
  11443. little, !is_unsigned);
  11444. }
  11445. }
  11446. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func) \
  11447. { \
  11448. func_type value = func(x); \
  11449. if (sizeof(target_type) < sizeof(func_type)) { \
  11450. if (unlikely(value != (func_type) (target_type) value)) { \
  11451. func_type zero = 0; \
  11452. PyErr_SetString(PyExc_OverflowError, \
  11453. (is_unsigned && unlikely(value < zero)) ? \
  11454. "can't convert negative value to " #target_type : \
  11455. "value too large to convert to " #target_type); \
  11456. return (target_type) -1; \
  11457. } \
  11458. } \
  11459. return (target_type) value; \
  11460. }
  11461. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  11462. #if CYTHON_USE_PYLONG_INTERNALS
  11463. #include "longintrepr.h"
  11464. #endif
  11465. #endif
  11466. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
  11467. const long neg_one = (long) -1, const_zero = 0;
  11468. const int is_unsigned = neg_one > const_zero;
  11469. #if PY_MAJOR_VERSION < 3
  11470. if (likely(PyInt_Check(x))) {
  11471. if (sizeof(long) < sizeof(long)) {
  11472. __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG)
  11473. } else {
  11474. long val = PyInt_AS_LONG(x);
  11475. if (is_unsigned && unlikely(val < 0)) {
  11476. PyErr_SetString(PyExc_OverflowError,
  11477. "can't convert negative value to long");
  11478. return (long) -1;
  11479. }
  11480. return (long) val;
  11481. }
  11482. } else
  11483. #endif
  11484. if (likely(PyLong_Check(x))) {
  11485. if (is_unsigned) {
  11486. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  11487. #if CYTHON_USE_PYLONG_INTERNALS
  11488. if (sizeof(digit) <= sizeof(long)) {
  11489. switch (Py_SIZE(x)) {
  11490. case 0: return 0;
  11491. case 1: return (long) ((PyLongObject*)x)->ob_digit[0];
  11492. }
  11493. }
  11494. #endif
  11495. #endif
  11496. if (unlikely(Py_SIZE(x) < 0)) {
  11497. PyErr_SetString(PyExc_OverflowError,
  11498. "can't convert negative value to long");
  11499. return (long) -1;
  11500. }
  11501. if (sizeof(long) <= sizeof(unsigned long)) {
  11502. __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong)
  11503. } else if (sizeof(long) <= sizeof(unsigned long long)) {
  11504. __PYX_VERIFY_RETURN_INT(long, unsigned long long, PyLong_AsUnsignedLongLong)
  11505. }
  11506. } else {
  11507. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  11508. #if CYTHON_USE_PYLONG_INTERNALS
  11509. if (sizeof(digit) <= sizeof(long)) {
  11510. switch (Py_SIZE(x)) {
  11511. case 0: return 0;
  11512. case 1: return +(long) ((PyLongObject*)x)->ob_digit[0];
  11513. case -1: return -(long) ((PyLongObject*)x)->ob_digit[0];
  11514. }
  11515. }
  11516. #endif
  11517. #endif
  11518. if (sizeof(long) <= sizeof(long)) {
  11519. __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong)
  11520. } else if (sizeof(long) <= sizeof(long long)) {
  11521. __PYX_VERIFY_RETURN_INT(long, long long, PyLong_AsLongLong)
  11522. }
  11523. }
  11524. {
  11525. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  11526. PyErr_SetString(PyExc_RuntimeError,
  11527. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  11528. #else
  11529. long val;
  11530. PyObject *v = __Pyx_PyNumber_Int(x);
  11531. #if PY_MAJOR_VERSION < 3
  11532. if (likely(v) && !PyLong_Check(v)) {
  11533. PyObject *tmp = v;
  11534. v = PyNumber_Long(tmp);
  11535. Py_DECREF(tmp);
  11536. }
  11537. #endif
  11538. if (likely(v)) {
  11539. int one = 1; int is_little = (int)*(unsigned char *)&one;
  11540. unsigned char *bytes = (unsigned char *)&val;
  11541. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  11542. bytes, sizeof(val),
  11543. is_little, !is_unsigned);
  11544. Py_DECREF(v);
  11545. if (likely(!ret))
  11546. return val;
  11547. }
  11548. #endif
  11549. return (long) -1;
  11550. }
  11551. } else {
  11552. long val;
  11553. PyObject *tmp = __Pyx_PyNumber_Int(x);
  11554. if (!tmp) return (long) -1;
  11555. val = __Pyx_PyInt_As_long(tmp);
  11556. Py_DECREF(tmp);
  11557. return val;
  11558. }
  11559. }
  11560. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  11561. #if CYTHON_USE_PYLONG_INTERNALS
  11562. #include "longintrepr.h"
  11563. #endif
  11564. #endif
  11565. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
  11566. const int neg_one = (int) -1, const_zero = 0;
  11567. const int is_unsigned = neg_one > const_zero;
  11568. #if PY_MAJOR_VERSION < 3
  11569. if (likely(PyInt_Check(x))) {
  11570. if (sizeof(int) < sizeof(long)) {
  11571. __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG)
  11572. } else {
  11573. long val = PyInt_AS_LONG(x);
  11574. if (is_unsigned && unlikely(val < 0)) {
  11575. PyErr_SetString(PyExc_OverflowError,
  11576. "can't convert negative value to int");
  11577. return (int) -1;
  11578. }
  11579. return (int) val;
  11580. }
  11581. } else
  11582. #endif
  11583. if (likely(PyLong_Check(x))) {
  11584. if (is_unsigned) {
  11585. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  11586. #if CYTHON_USE_PYLONG_INTERNALS
  11587. if (sizeof(digit) <= sizeof(int)) {
  11588. switch (Py_SIZE(x)) {
  11589. case 0: return 0;
  11590. case 1: return (int) ((PyLongObject*)x)->ob_digit[0];
  11591. }
  11592. }
  11593. #endif
  11594. #endif
  11595. if (unlikely(Py_SIZE(x) < 0)) {
  11596. PyErr_SetString(PyExc_OverflowError,
  11597. "can't convert negative value to int");
  11598. return (int) -1;
  11599. }
  11600. if (sizeof(int) <= sizeof(unsigned long)) {
  11601. __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong)
  11602. } else if (sizeof(int) <= sizeof(unsigned long long)) {
  11603. __PYX_VERIFY_RETURN_INT(int, unsigned long long, PyLong_AsUnsignedLongLong)
  11604. }
  11605. } else {
  11606. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  11607. #if CYTHON_USE_PYLONG_INTERNALS
  11608. if (sizeof(digit) <= sizeof(int)) {
  11609. switch (Py_SIZE(x)) {
  11610. case 0: return 0;
  11611. case 1: return +(int) ((PyLongObject*)x)->ob_digit[0];
  11612. case -1: return -(int) ((PyLongObject*)x)->ob_digit[0];
  11613. }
  11614. }
  11615. #endif
  11616. #endif
  11617. if (sizeof(int) <= sizeof(long)) {
  11618. __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong)
  11619. } else if (sizeof(int) <= sizeof(long long)) {
  11620. __PYX_VERIFY_RETURN_INT(int, long long, PyLong_AsLongLong)
  11621. }
  11622. }
  11623. {
  11624. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  11625. PyErr_SetString(PyExc_RuntimeError,
  11626. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  11627. #else
  11628. int val;
  11629. PyObject *v = __Pyx_PyNumber_Int(x);
  11630. #if PY_MAJOR_VERSION < 3
  11631. if (likely(v) && !PyLong_Check(v)) {
  11632. PyObject *tmp = v;
  11633. v = PyNumber_Long(tmp);
  11634. Py_DECREF(tmp);
  11635. }
  11636. #endif
  11637. if (likely(v)) {
  11638. int one = 1; int is_little = (int)*(unsigned char *)&one;
  11639. unsigned char *bytes = (unsigned char *)&val;
  11640. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  11641. bytes, sizeof(val),
  11642. is_little, !is_unsigned);
  11643. Py_DECREF(v);
  11644. if (likely(!ret))
  11645. return val;
  11646. }
  11647. #endif
  11648. return (int) -1;
  11649. }
  11650. } else {
  11651. int val;
  11652. PyObject *tmp = __Pyx_PyNumber_Int(x);
  11653. if (!tmp) return (int) -1;
  11654. val = __Pyx_PyInt_As_int(tmp);
  11655. Py_DECREF(tmp);
  11656. return val;
  11657. }
  11658. }
  11659. static int __Pyx_check_binary_version(void) {
  11660. char ctversion[4], rtversion[4];
  11661. PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
  11662. PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
  11663. if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
  11664. char message[200];
  11665. PyOS_snprintf(message, sizeof(message),
  11666. "compiletime version %s of module '%.100s' "
  11667. "does not match runtime version %s",
  11668. ctversion, __Pyx_MODULE_NAME, rtversion);
  11669. #if PY_VERSION_HEX < 0x02050000
  11670. return PyErr_Warn(NULL, message);
  11671. #else
  11672. return PyErr_WarnEx(NULL, message, 1);
  11673. #endif
  11674. }
  11675. return 0;
  11676. }
  11677. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  11678. int start = 0, mid = 0, end = count - 1;
  11679. if (end >= 0 && code_line > entries[end].code_line) {
  11680. return count;
  11681. }
  11682. while (start < end) {
  11683. mid = (start + end) / 2;
  11684. if (code_line < entries[mid].code_line) {
  11685. end = mid;
  11686. } else if (code_line > entries[mid].code_line) {
  11687. start = mid + 1;
  11688. } else {
  11689. return mid;
  11690. }
  11691. }
  11692. if (code_line <= entries[mid].code_line) {
  11693. return mid;
  11694. } else {
  11695. return mid + 1;
  11696. }
  11697. }
  11698. static PyCodeObject *__pyx_find_code_object(int code_line) {
  11699. PyCodeObject* code_object;
  11700. int pos;
  11701. if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
  11702. return NULL;
  11703. }
  11704. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  11705. if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
  11706. return NULL;
  11707. }
  11708. code_object = __pyx_code_cache.entries[pos].code_object;
  11709. Py_INCREF(code_object);
  11710. return code_object;
  11711. }
  11712. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
  11713. int pos, i;
  11714. __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
  11715. if (unlikely(!code_line)) {
  11716. return;
  11717. }
  11718. if (unlikely(!entries)) {
  11719. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  11720. if (likely(entries)) {
  11721. __pyx_code_cache.entries = entries;
  11722. __pyx_code_cache.max_count = 64;
  11723. __pyx_code_cache.count = 1;
  11724. entries[0].code_line = code_line;
  11725. entries[0].code_object = code_object;
  11726. Py_INCREF(code_object);
  11727. }
  11728. return;
  11729. }
  11730. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  11731. if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
  11732. PyCodeObject* tmp = entries[pos].code_object;
  11733. entries[pos].code_object = code_object;
  11734. Py_DECREF(tmp);
  11735. return;
  11736. }
  11737. if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
  11738. int new_max = __pyx_code_cache.max_count + 64;
  11739. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  11740. __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry));
  11741. if (unlikely(!entries)) {
  11742. return;
  11743. }
  11744. __pyx_code_cache.entries = entries;
  11745. __pyx_code_cache.max_count = new_max;
  11746. }
  11747. for (i=__pyx_code_cache.count; i>pos; i--) {
  11748. entries[i] = entries[i-1];
  11749. }
  11750. entries[pos].code_line = code_line;
  11751. entries[pos].code_object = code_object;
  11752. __pyx_code_cache.count++;
  11753. Py_INCREF(code_object);
  11754. }
  11755. #include "compile.h"
  11756. #include "frameobject.h"
  11757. #include "traceback.h"
  11758. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  11759. const char *funcname, int c_line,
  11760. int py_line, const char *filename) {
  11761. PyCodeObject *py_code = 0;
  11762. PyObject *py_srcfile = 0;
  11763. PyObject *py_funcname = 0;
  11764. #if PY_MAJOR_VERSION < 3
  11765. py_srcfile = PyString_FromString(filename);
  11766. #else
  11767. py_srcfile = PyUnicode_FromString(filename);
  11768. #endif
  11769. if (!py_srcfile) goto bad;
  11770. if (c_line) {
  11771. #if PY_MAJOR_VERSION < 3
  11772. py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  11773. #else
  11774. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  11775. #endif
  11776. }
  11777. else {
  11778. #if PY_MAJOR_VERSION < 3
  11779. py_funcname = PyString_FromString(funcname);
  11780. #else
  11781. py_funcname = PyUnicode_FromString(funcname);
  11782. #endif
  11783. }
  11784. if (!py_funcname) goto bad;
  11785. py_code = __Pyx_PyCode_New(
  11786. 0, /*int argcount,*/
  11787. 0, /*int kwonlyargcount,*/
  11788. 0, /*int nlocals,*/
  11789. 0, /*int stacksize,*/
  11790. 0, /*int flags,*/
  11791. __pyx_empty_bytes, /*PyObject *code,*/
  11792. __pyx_empty_tuple, /*PyObject *consts,*/
  11793. __pyx_empty_tuple, /*PyObject *names,*/
  11794. __pyx_empty_tuple, /*PyObject *varnames,*/
  11795. __pyx_empty_tuple, /*PyObject *freevars,*/
  11796. __pyx_empty_tuple, /*PyObject *cellvars,*/
  11797. py_srcfile, /*PyObject *filename,*/
  11798. py_funcname, /*PyObject *name,*/
  11799. py_line, /*int firstlineno,*/
  11800. __pyx_empty_bytes /*PyObject *lnotab*/
  11801. );
  11802. Py_DECREF(py_srcfile);
  11803. Py_DECREF(py_funcname);
  11804. return py_code;
  11805. bad:
  11806. Py_XDECREF(py_srcfile);
  11807. Py_XDECREF(py_funcname);
  11808. return NULL;
  11809. }
  11810. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  11811. int py_line, const char *filename) {
  11812. PyCodeObject *py_code = 0;
  11813. PyObject *py_globals = 0;
  11814. PyFrameObject *py_frame = 0;
  11815. py_code = __pyx_find_code_object(c_line ? c_line : py_line);
  11816. if (!py_code) {
  11817. py_code = __Pyx_CreateCodeObjectForTraceback(
  11818. funcname, c_line, py_line, filename);
  11819. if (!py_code) goto bad;
  11820. __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
  11821. }
  11822. py_globals = PyModule_GetDict(__pyx_m);
  11823. if (!py_globals) goto bad;
  11824. py_frame = PyFrame_New(
  11825. PyThreadState_GET(), /*PyThreadState *tstate,*/
  11826. py_code, /*PyCodeObject *code,*/
  11827. py_globals, /*PyObject *globals,*/
  11828. 0 /*PyObject *locals*/
  11829. );
  11830. if (!py_frame) goto bad;
  11831. py_frame->f_lineno = py_line;
  11832. PyTraceBack_Here(py_frame);
  11833. bad:
  11834. Py_XDECREF(py_code);
  11835. Py_XDECREF(py_frame);
  11836. }
  11837. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
  11838. while (t->p) {
  11839. #if PY_MAJOR_VERSION < 3
  11840. if (t->is_unicode) {
  11841. *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
  11842. } else if (t->intern) {
  11843. *t->p = PyString_InternFromString(t->s);
  11844. } else {
  11845. *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
  11846. }
  11847. #else /* Python 3+ has unicode identifiers */
  11848. if (t->is_unicode | t->is_str) {
  11849. if (t->intern) {
  11850. *t->p = PyUnicode_InternFromString(t->s);
  11851. } else if (t->encoding) {
  11852. *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
  11853. } else {
  11854. *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
  11855. }
  11856. } else {
  11857. *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
  11858. }
  11859. #endif
  11860. if (!*t->p)
  11861. return -1;
  11862. ++t;
  11863. }
  11864. return 0;
  11865. }
  11866. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char* c_str) {
  11867. return __Pyx_PyUnicode_FromStringAndSize(c_str, strlen(c_str));
  11868. }
  11869. static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
  11870. Py_ssize_t ignore;
  11871. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  11872. }
  11873. static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  11874. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  11875. if (
  11876. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  11877. __Pyx_sys_getdefaultencoding_not_ascii &&
  11878. #endif
  11879. PyUnicode_Check(o)) {
  11880. #if PY_VERSION_HEX < 0x03030000
  11881. char* defenc_c;
  11882. PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
  11883. if (!defenc) return NULL;
  11884. defenc_c = PyBytes_AS_STRING(defenc);
  11885. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  11886. {
  11887. char* end = defenc_c + PyBytes_GET_SIZE(defenc);
  11888. char* c;
  11889. for (c = defenc_c; c < end; c++) {
  11890. if ((unsigned char) (*c) >= 128) {
  11891. PyUnicode_AsASCIIString(o);
  11892. return NULL;
  11893. }
  11894. }
  11895. }
  11896. #endif /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/
  11897. *length = PyBytes_GET_SIZE(defenc);
  11898. return defenc_c;
  11899. #else /* PY_VERSION_HEX < 0x03030000 */
  11900. if (PyUnicode_READY(o) == -1) return NULL;
  11901. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  11902. if (PyUnicode_IS_ASCII(o)) {
  11903. *length = PyUnicode_GET_DATA_SIZE(o);
  11904. return PyUnicode_AsUTF8(o);
  11905. } else {
  11906. PyUnicode_AsASCIIString(o);
  11907. return NULL;
  11908. }
  11909. #else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
  11910. return PyUnicode_AsUTF8AndSize(o, length);
  11911. #endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
  11912. #endif /* PY_VERSION_HEX < 0x03030000 */
  11913. } else
  11914. #endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */
  11915. #if !CYTHON_COMPILING_IN_PYPY
  11916. #if PY_VERSION_HEX >= 0x02060000
  11917. if (PyByteArray_Check(o)) {
  11918. *length = PyByteArray_GET_SIZE(o);
  11919. return PyByteArray_AS_STRING(o);
  11920. } else
  11921. #endif
  11922. #endif
  11923. {
  11924. char* result;
  11925. int r = PyBytes_AsStringAndSize(o, &result, length);
  11926. if (unlikely(r < 0)) {
  11927. return NULL;
  11928. } else {
  11929. return result;
  11930. }
  11931. }
  11932. }
  11933. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  11934. int is_true = x == Py_True;
  11935. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  11936. else return PyObject_IsTrue(x);
  11937. }
  11938. static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  11939. PyNumberMethods *m;
  11940. const char *name = NULL;
  11941. PyObject *res = NULL;
  11942. #if PY_MAJOR_VERSION < 3
  11943. if (PyInt_Check(x) || PyLong_Check(x))
  11944. #else
  11945. if (PyLong_Check(x))
  11946. #endif
  11947. return Py_INCREF(x), x;
  11948. m = Py_TYPE(x)->tp_as_number;
  11949. #if PY_MAJOR_VERSION < 3
  11950. if (m && m->nb_int) {
  11951. name = "int";
  11952. res = PyNumber_Int(x);
  11953. }
  11954. else if (m && m->nb_long) {
  11955. name = "long";
  11956. res = PyNumber_Long(x);
  11957. }
  11958. #else
  11959. if (m && m->nb_int) {
  11960. name = "int";
  11961. res = PyNumber_Long(x);
  11962. }
  11963. #endif
  11964. if (res) {
  11965. #if PY_MAJOR_VERSION < 3
  11966. if (!PyInt_Check(res) && !PyLong_Check(res)) {
  11967. #else
  11968. if (!PyLong_Check(res)) {
  11969. #endif
  11970. PyErr_Format(PyExc_TypeError,
  11971. "__%.4s__ returned non-%.4s (type %.200s)",
  11972. name, name, Py_TYPE(res)->tp_name);
  11973. Py_DECREF(res);
  11974. return NULL;
  11975. }
  11976. }
  11977. else if (!PyErr_Occurred()) {
  11978. PyErr_SetString(PyExc_TypeError,
  11979. "an integer is required");
  11980. }
  11981. return res;
  11982. }
  11983. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  11984. #if CYTHON_USE_PYLONG_INTERNALS
  11985. #include "longintrepr.h"
  11986. #endif
  11987. #endif
  11988. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  11989. Py_ssize_t ival;
  11990. PyObject *x;
  11991. #if PY_MAJOR_VERSION < 3
  11992. if (likely(PyInt_CheckExact(b)))
  11993. return PyInt_AS_LONG(b);
  11994. #endif
  11995. if (likely(PyLong_CheckExact(b))) {
  11996. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  11997. #if CYTHON_USE_PYLONG_INTERNALS
  11998. switch (Py_SIZE(b)) {
  11999. case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0];
  12000. case 0: return 0;
  12001. case 1: return ((PyLongObject*)b)->ob_digit[0];
  12002. }
  12003. #endif
  12004. #endif
  12005. #if PY_VERSION_HEX < 0x02060000
  12006. return PyInt_AsSsize_t(b);
  12007. #else
  12008. return PyLong_AsSsize_t(b);
  12009. #endif
  12010. }
  12011. x = PyNumber_Index(b);
  12012. if (!x) return -1;
  12013. ival = PyInt_AsSsize_t(x);
  12014. Py_DECREF(x);
  12015. return ival;
  12016. }
  12017. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
  12018. #if PY_VERSION_HEX < 0x02050000
  12019. if (ival <= LONG_MAX)
  12020. return PyInt_FromLong((long)ival);
  12021. else {
  12022. unsigned char *bytes = (unsigned char *) &ival;
  12023. int one = 1; int little = (int)*(unsigned char*)&one;
  12024. return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
  12025. }
  12026. #else
  12027. return PyInt_FromSize_t(ival);
  12028. #endif
  12029. }
  12030. #endif /* Py_PYTHON_H */