Yaml Reader For Mac

In this episode we show you how to work with YAML files in Ruby Full Post - Facebook - http://facebook.com/co. Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site. I've been working up to some larger projects as I learn Go. One of my current projects now needs the ability to parse a configuration file. I've looked at a few of the existing options. There are parsers for Windows-style INI files, YAML files, JSON files, and one for Java-like Properties files. I've always preferred.

Permalink

Join GitHub today

GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Sign up
Find file Copy path
Cannot retrieve contributors at this time
#!/usr/bin/python
#########################################################################
# #
# This script is meant to convert the csv file containg the OSX/iOS #
# artifacts into a yaml artifact page #
# #
# Author: Pasquale Stirparo (@pstirparo) #
# #
# This work is licensed under the GNU General Public licensed #
# #
#########################################################################
import sys
import os
import csv
import argparse
from datetime import date
__author__ ='@pstirparo'
__version__='0.2'
__location__ ='https://github.com/pstirparo/mac4n6'
__ref1__ ='http://forensicswiki.org/wiki/Mac_OS_X'
__ref2__ ='http://forensicswiki.org/wiki/Mac_OS_X_10.9_-_Artifacts_Location'
flag_openrow =False
defwrite_artifact(artifact, yamlF):
yamlF.write('name: '+ artifact['name'] +'n')
yamlF.write('doc: '+ artifact['doc'] +'n')
yamlF.write('sources:n')
yamlF.write('- type: FILEn')
#yamlF.write(' attributes:n')
tmp = artifact['paths'].split(',')
ifint(len(tmp)) >1:
yamlF.write(' attributes:n')
yamlF.write(' paths: n')
for path in tmp:
yamlF.write(' - ''+ path +''n')
else:
yamlF.write(' attributes: ')
yamlF.write('{paths: [''+ artifact['paths'] +'']}n')
yamlF.write('labels: ['+ artifact['labels'] +']n')
yamlF.write('supported_os: [Darwin]n')
ifint(len(artifact['urls'])) >0:
yamlF.write('urls: [''+ artifact['urls'] +'']n')
yamlF.write('---n')
defmain():
global flag_openrow
artifact = {}
artifacts_counter, locations_counter =0, 0
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--input', dest='csv_input', default=False, help='CSV Artifacts file to be converted into YAML', metavar='')
iflen(sys.argv) 1:
parser.print_help()
sys.exit(1)
try:
args = parser.parse_args()
except:
parser.print_help()
sys.exit(0)
csv_file = args.csv_input
yaml_file = os.path.splitext(csv_file)[0] +'.yaml'
withopen(yaml_file, 'w+') as yamlF:
yamlF.write('# Mac OS X (Darwin) specific artifacts.n')
yamlF.write('# mac4n6: '+ __location__ +'n')
yamlF.write('# Reference: '+ __ref1__ +'n')
yamlF.write('# Reference: '+ __ref2__ +'n')
yamlF.write('# Last update: '+ date.today().isoformat() +'nn')
withopen(csv_file, 'rU') asfile:
reader = csv.reader(file, delimiter=',')
#skip the first 3 lines of the csv file
for i inrange(3):
next(reader)
for row in reader:
iflen(row) >0:
ifint(len(row[0])) >1andint(len(row[1])) >1:
#Check if current row is the intermediate section header and skip
if row[0] 'Artifact'and row[1] 'Name':
continue
if flag_openrow True:
write_artifact(artifact, yamlF)
flag_openrow =False
artifact['name'] = row[1]
artifact['doc'] = row[0]
artifact['paths'] = row[3]
artifact['labels'] = row[2]
artifact['urls'] = row[5]
flag_openrow =True
artifacts_counter+=1
locations_counter+=1
elifint(len(row[0])) 1:
artifact['paths'] = artifact['paths'] +','+ row[3]
locations_counter+=1
if flag_openrow True:
write_artifact(artifact, yamlF)
yamlF.write('# Total Artifacts: '+str(artifacts_counter) +'n')
yamlF.write('# Total Locations: '+str(locations_counter) +'n')
if__name__'__main__':
main()
Adobe acrobat reader for mac

Acrobat Reader For Mac

  • Copy lines
  • Copy permalink