-- Format adding helpers
350846
function addCoreFormats() {
        forEach(CoreParsingFormats, function(df) {
          var src = df.src;
          if (df.localeCheck && !df.localeCheck(loc)) {
            return;
          }
          if (df.mdy && loc.mdy) {
            // Use the mm/dd/yyyy variant if it
            // exists and the locale requires it
            src = df.mdy;
          }
          if (df.time) {
            // Core formats that allow time require the time
            // reg on both sides, so add both versions here.
            loc.addFormat(getFormatWithTime(src, true));
            loc.addFormat(getFormatWithTime(src));
          } else {
            loc.addFormat(src);
          }
        });
        loc.addFormat('{time}');
      }
1104041
def add_formatter(self, sqla_col_type, formatter, key_specific=None):
        
        self.add_item(sqla_col_type, formatter, key_specific)
103808
function (format) {
  throw new Error(index$1.red('[indian-ocean] You passed in an object but converting to ' + index$1.bold(format) + ' requires a list of objects.') + index$1.cyan('\nIf you would like to write a one-row csv, put your object in a list like so: `' + index$1.bold('[data]') + '`\n'));
}
56173
function formatValue(value) {
		
		var out;
		var type = util.sType(value);
		
		// if there is a type, check all sub items for types
		if (_.has(value, 'attributes.type') && _.has(value, '$value') && _.keys(value).length === 2) {
			out = util.moRef(value);
		}
		else if (type) {
			if (util.isArray(value)) {
				out = [];
				
				var subtype = type;
				
				if (subtype.match(/^ArrayOf/)) {
					subtype = subtype.replace(/^ArrayOf/, '');

					if (!Array.isArray(_.get(value, subtype)) && value[subtype]) {
						value[subtype] = [value[subtype]];
					}
				}
				
				_.forEach(value[_.keys(value)[1]], function(obj) {
					out.push(formatValue(obj));
				});
			}
			else if (util.isBoolean(value)) {
				
				// check for valid true values, otherwise false
				if (_.includes(['1', 'true'], _.lowerCase(value.$value))) {
					out = true;
				}
				else {
					out = false;
				}
			}
			else if (util.isInt(value)) {
				out = Number(value.$value);
			}
			else if (_.has(value, '$value')) {
				out = value.$value;
			}
			else {
				out = formatValue(_.omit(value, 'attributes'));
			}
			
		}
		else if (Array.isArray(value)) {
			out = [];
			_.forEach(value, function(val) {
				if (util.sType(val) || util.isArray(val) || util.hasKeys(val)) {
					out.push(formatValue(val));
				}
				else {
					out.push(cast(val));
				}
			});
		}
		else if (util.hasKeys(value)) {
			out = {};
			_.forEach(value, function(val, key) {
				if (util.sType(val) || util.isArray(val) || util.hasKeys(val)) {
					out[key] = formatValue(val);
				}
				else {
					out[key] = cast(val);
				}
			});
		}
		else {
			out = cast(value);
		}
		return out;
	}
818329
function formatInput(val, countryCode, addSuffix, allowExtension, isAllowedKey) {
    try {
        var clean = val.replace(/\D/g, ""),
            // NOTE: we use AsYouTypeFormatter because the default format function can't handle incomplete numbers e.g. "+17024" formats to "+1 7024" as opposed to "+1 702-4"
            formatter = new i18n.phonenumbers.AsYouTypeFormatter(countryCode),
            // if clean is empty, we still need this to be a string otherwise we get errors later
            result = "",
            next,
            extSuffix = " ext. ";

        if (val.substr(0, 1) == "+") {
            clean = "+" + clean;
        }

        for (var i = 0; i < clean.length; i++) {
            // TODO: improve this so don't just pump in every digit every time - we should just cache this formatter object, and just call inputDigit once each time the user enters a new digit
            next = formatter.inputDigit(clean.charAt(i));
            // if adding this char didn't change the length, or made it smaller (and there's no longer any spaces): that means that formatting failed which means the number was no longer a potentially valid number, so if we're allowing extensions: assume the rest is the ext
            if (allowExtension && result && next.length <= result.length && next.indexOf(" ") == -1) {
                // set flag for extension
                next = -1;
                break;
            }
            result = next;
        }

        // for some reason libphonenumber formats "+44" to "+44 ", but doesn't do the same with "+1"
        if (result.charAt(result.length - 1) == " ") {
            result = result.substr(0, result.length - 1);
        }
        // check if there's a suffix to add (unless there's an ext)
        if (addSuffix && !val.split(extSuffix)[1]) {
            // hack to get formatting suffix
            var test = formatter.inputDigit('5');
            // again the "+44 " problem... (also affects "+45" apparently)
            if (test.charAt(test.length - 1) == " ") {
                test = test.substr(0, test.length - 1);
            }
            // if adding a '5' introduces a formatting char - check if the penultimate char is not-a-number
            var penultimate = test.substr(test.length - 2, 1);
            // Note: never use isNaN without parseFloat
            if (isNaN(parseFloat(penultimate))) {
                // return the new value (minus that last '5' we just added)
                return test.substr(0, test.length - 1);
            } else if (allowExtension && result && test.length <= result.length && test.indexOf(" ") == -1 && !isAllowedKey) {
                // else if the next digit would break the formating, and we're allowing extensions, AND this is not an allowed key: add the suffix
                // NOTE: we must check this is not an allowed key because if it was that means it was the last digit in a valid number and we dont want to add the "ext" suffix in that case. This whole condition is just here to catch the case that: after typing a valid number, they try to type "ext" - this will not automatically add it for them.
                return result + extSuffix;
            }
        }

        // if the clean number contains an extension we need to add it
        if (next == -1) {
            result += extSuffix + clean.substring(i, clean.length);
        }

        return result;
    } catch (e) {
        return val;
    }
}
686918
def format_options(self, ctx, formatter):
        """"""
        opts = []
        for param in self.get_params(ctx):
            rv = param.get_help_record(ctx)
            if rv is not None:
                opts.append(rv)

        if opts:
            with formatter.section('Options'):
                formatter.write_dl(opts)
824526
def setup_formats(self):
        
        methods = self.get_methods()
        for m in methods:
            #Methods named "from_X" will be assumed to convert from format X to the common format
            if m.startswith("from_"):
                self.input_formats.append(re.sub("from_" , "",m))
            #Methods named "to_X" will be assumed to convert from the common format to X
            elif m.startswith("to_"):
                self.output_formats.append(re.sub("to_","",m))
607848
function preset (key, format) {
  validator('format', format)

  if (presets[key] !== undefined) {
    throw new SyntaxError('It is not allowed to override existing presets.')
  }

  presets[key] = format
}
97666
function helper(app, file, key, re) {
  var h = get(app._.asyncHelpers, key);
  var a = get(app._.helpers, key);

  if (!h && !a) {
    set(file.data, key, function () {
      return comment(key, 'helper');
    });

    if (re.test(file.content)) {
      var message = 'MISSING helper: "' + key + '".\n';
      // rethrow (or actually throw) the error
      var err = new SyntaxError(message);
      if (app.disabled('silent')) {
        rethrow(err, file.path, file.content, re);
      }
    }
  }
}
1350526
function Formatter(format, timeFormat) {
	format = format || '%(message)';
	timeFormat = timeFormat || '%Y-%m-%d %H:%M:%S';

	/**
	 * @private
	 * @type {string}
	 */
	this._format = format;

	/**
	 * @private
	 * @type {string}
	 */
	this._timeFormat = timeFormat;
}
1029163
def format_help(self, ctx, formatter):
        
        self.format_usage(ctx, formatter)
        self.format_help_text(ctx, formatter)
        self.format_options(ctx, formatter)
        self.format_epilog(ctx, formatter)
633614
function toJalaliFormat(format) {
    for (var i = 0; i < format.length; i++) {
        if(!i || (format[i-1] !== "j" && format[i-1] !== format[i])) {
            if (format[i] === "Y" || format[i] === "M" || format[i] === "D" || format[i] === "g") {
                format = format.slice(0, i) + "j" + format.slice(i);
            }
        }
    }
    return format;
}
1088704
function TableFormatter(options) {
  const table = new Table(options);
  this.format = format;
  function format(result, formatOptions) {
    let data = [];
    _.each(result, function (item) {
      data.push(_.values(_.pick(item, options.values)));
    });
    if (formatOptions.format === 'csv') {
     _.each(data, function(row) {
       console.log(row.join(','));
     });
    } else if ( formatOptions.format === 'json') {
      console.log(JSON.stringify(result));
    } else {
      table.push.apply(table, data);
      console.log(table.toString());
    }
  }
}
1107768
function processFormat( value, src, dst ) {
  if( !dst.format ) return value;
  try {
    if( !Array.isArray( dst.format ) )
      throw "Must be an array with two elements!";
    var intlFunc = dst.format[0];
    if( typeof intlFunc !== 'function' )
      throw "First element of the array must be a function!";
    var intlId = dst.format[1];
    if( typeof intlId !== 'string' )
      throw "Second element of the array must be a string!";
    return intlFunc( intlId, value );
  }
  catch( ex ) {
    console.error( ex );
    fail(
      "Error in format of link "
        + PropertyManager(src.obj) + "." + src.name
        + " -> "
        + PropertyManager(dst.obj) + "." + dst.name + "!\n"
        + ex
    );
  }
}
934648
def options_formatting(self):
        
        group = self.parser.add_argument_group("Format")
        group.add_argument(
            "--format", dest="formatting", default=None,
            help="Custom output format using the {} expansion")
        group.add_argument(
            "--value", dest="values", action="append", default=[],
            help="Values for the custom formatting string")
1245618
def add_format format
      if format.is_a? Workbook::Format
        if format.name
          @formats[format.name]=format
        else
          @formats[@formats.keys.count]=format
        end
      else
        raise ArgumentError, "format should be a Workboot::Format"
      end
    end
384644
function(format, value) {
      var date = helpers.date.parse(value);

      if(date === false || date === undefined) return false;

      var day = date.getDate().toString().replace(/(?=(^\d{1}$))/g, "0");
      var month = (date.getMonth() + 1).toString().replace(/(?=(^\d{1}$))/g, "0");

      var formatDate = format
         .replace(/dd/gi, day)
         .replace(/mm/gi, month)
         .replace(/yyyy/gi, date.getFullYear());

      return formatDate;
   }