{"id":395,"date":"2007-11-26T07:25:55","date_gmt":"2007-11-26T11:25:55","guid":{"rendered":"http:\/\/www.dr-chuck.com\/wordpress\/?p=395"},"modified":"2011-12-17T12:24:27","modified_gmt":"2011-12-17T16:24:27","slug":"playing-with-python-notes","status":"publish","type":"post","link":"https:\/\/www.dr-chuck.com\/csev-blog\/2007\/11\/playing-with-python-notes\/","title":{"rendered":"Playing With Python &#8211; Notes"},"content":{"rendered":"<p>\nJust some notes &#8211; I am trying to build a python script to fix the dates on my files.  I mistakenly use cp instead of tar to restore my home directory during my upgrade to Leopard. So now I have to go through and patch all of the files modification times from the backup.<\/p>\n<p>\nIt should be a fun exercise in Python.  Notes below<\/p>\n<p><!--more--><br \/>\nwalk(p, visit, arg)\tCalls the function visit with arguments(arg,dirname,names) for each directory recursively in the directory tree rooted at p (including p itself if it&#8217;s a dir.) The argument dirname specifies the visited directory, the argument names lists the files in the directory. The visit function may modify names to influence the set of directories visited belowdirname, e.g., to avoid visiting certain parts of the tree<\/p>\n<pre>\n>>> from datetime import datetime\n>>> now = datetime.utcnow()\n>>> z = datetime.utcfromtimestamp(x)\n>>> print z\n2007-11-09 21:14:36\n>>> print z.year\n2007\n>>>\n-t      Change the access and modification times to the specified time.\nThe argument should be in the form ``[[CC]YY]MMDDhhmm[.SS]''\nwhere each pair of letters represents the following:\nCC      The first two digits of the year (the century).\nYY      The second two digits of the year.  If ``YY'' is\nspecified, but ``CC'' is not, a value for ``YY''\nbetween 69 and 99 results in a ``CC'' value of 19.\nOtherwise, a ``CC'' value of 20 is used.\nMM      The month of the year, from 1 to 12.\nDD      the day of the month, from 1 to 31.\nhh      The hour of the day, from 0 to 23.\nmm      The minute of the hour, from 0 to 59.\nSS      The second of the minute, from 0 to 61.\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Just some notes &#8211; I am trying to build a python script to fix the dates on my files. I mistakenly use cp instead of tar to restore my home directory during my upgrade to Leopard. So now I have to go through and patch all of the files modification times from the backup. It [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-395","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/comments?post=395"}],"version-history":[{"count":1,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/395\/revisions"}],"predecessor-version":[{"id":2482,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/395\/revisions\/2482"}],"wp:attachment":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/media?parent=395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/categories?post=395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/tags?post=395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}