<commit_before>module.exports.getPhotoDates = getPhotoDates
module.exports.getPhotos = getPhotosFromDirectory

const path = require('path')
const fs = require('fs')
const ExifImage = require('exif').ExifImage

function getPhotoDates (directoryPath) {
  var photoDates = getPhotosFromDirectory(directoryPath, parseDateFromPhotos)
  console.log(photoDates)
  return
}

function getPhotosFromDirectory (directoryPath, callback) {
  if (!fs.existsSync(directoryPath)) {
    console.log('ERROR: filepath does not exist at ' + directoryPath)
    return
  }
  var filter = /\.jpg$/
  var files = fs.readdirSync(directoryPath)
  for (var i = 0; i < files.length; i++) {
    var fPath = path.join(directoryPath, files[i])
    if (fs.lstatSync(fPath).isDirectory()) {
      getPhotosFromDirectory(fPath, callback)
    } else if (filter.test(fPath)) {
      return callback(fPath)
    }
  }
}

function parseDateFromPhotos (filepath) {
  try {
    var imageDate = new ExifImage({image: filepath}, function (err, exifData) {
      if (err) {
        console.log('ERROR: ' + err.message)
        return
      } else {
        return exifData['exif']['CreateDate']
      }
    })
    return imageDate
  } catch (err) {
    console.log('ERROR: ' + err.message)
    return
  }
}<commit_msg>Committing to make a note about an idea...<commit_after>module.exports.getPhotoDates = getPhotoDates
module.exports.getPhotos = getPhotosFromDirectory

const path = require('path')
const fs = require('fs')
const ExifImage = require('exif').ExifImage

var photoDates

function populatePhotoDates (directoryPath) {
  photoDates.push(getPhotosFromDirectory(directoryPath, parseDateFromPhotos))
  console.log(photoDates)
  return
}

function getPhotosFromDirectory (directoryPath, callback) {
  if (!fs.existsSync(directoryPath)) {
    console.log('ERROR: filepath does not exist at ' + directoryPath)
    return
  }
  var filter = /\.jpg$/
  var files = fs.readdirSync(directoryPath)
  for (var i = 0; i < files.length; i++) {
    var fPath = path.join(directoryPath, files[i])
    if (fs.lstatSync(fPath).isDirectory()) {
      getPhotosFromDirectory(fPath, callback)
    } else if (filter.test(fPath)) {
      return callback(fPath)
    }
  }
}

function parseDateFromPhotos (filepath) {
  try {
    var imageDate = new ExifImage({image: filepath}, function (err, exifData) {
      if (err) {
        console.log('ERROR: ' + err.message)
        return
      } else {
        return exifData['exif']['CreateDate']
      }
    })
    return imageDate
  } catch (err) {
    console.log('ERROR: ' + err.message)
    return
  }
}


{'fraction_non_alphanumeric': 0.12346153846153846, 'fraction_numerical': 0.0007692307692307692, 'mean_word_length': 3.5631578947368423, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2727638', 'n_tokens_mistral': 848, 'n_tokens_neox': 824, 'n_words': 185}