<commit_before>import python.lib.Time;


@:coreApi
class Sys {

	static var environ:haxe.ds.StringMap<String>;

	public static function time():Float {
		return Time.time()/1000;
	}

	public static function exit(code:Int):Void {
		python.lib.Sys.exit(code);
	}

	public static function print(v:Dynamic):Void {
		python.Lib.print(v);
	}

	public static function println(v:Dynamic):Void {
		python.Lib.println(v);
	}

	public static function args() : Array<String> {
		var argv = python.lib.Sys.argv;
		return argv.slice(1);
	}

	public static function getEnv( s : String ) : String {
		return environ.get(s);
	}

	public static function putEnv( s : String, v : String ) : Void {
		environ.set(s, v);
	}

	public static function environment() : haxe.ds.StringMap<String> {
		return environ;
	}

	public static function sleep( seconds : Float ) : Void {
		python.lib.Time.sleep(seconds);
	}

	public static function setTimeLocale( loc : String ) : Bool {
		return false;
	}

	public static function getCwd() : String {
		return python.lib.Os.getcwd();
	}

	public static function setCwd( s : String ) : Void {
		python.lib.Os.chdir(s);
	}

	public static function systemName() : String {
		return "";
	}

	public static function command( cmd : String, ?args : Array<String> ) : Int {
		var args = args == null ? [cmd] : [cmd].concat(args);
		return python.lib.Subprocess.call(args);
	}

	public static function cpuTime() : Float {
		return 0.0;
	}

	public static function executablePath() : String {
		return python.lib.Sys.argv[0];
	}

	public static function getChar( echo : Bool ) : Int {

		var ch = switch (python.lib.Sys.platform) {
			case x if (StringTools.startsWith(x, "linux") || x =="darwin"):
				var fd = python.lib.Sys.stdin.fileno();
				var old = python.lib.Termios.tcgetattr(fd);

				var restore = python.lib.Termios.tcsetattr.bind(fd, python.lib.Termios.TCSADRAIN, old);

				try {
					python.lib.Tty.setraw(fd);
					var x = python.lib.Sys.stdin.read(1);
					restore();
					x.charCodeAt(0);
				} catch (e:Dynamic) {
					restore();
					throw e;
				}

			case "win32" | "cygwin":
				python.lib.Msvcrt.getch().decode("utf-8").charCodeAt(0);
			case x :
				throw "platform " + x + " not supported";
		}
		if (echo) {
			python.Lib.print(String.fromCharCode(ch));
		}
		return ch;
	}

	public static function stdin() : haxe.io.Input {
		return null;
	}

	public static function stdout() : haxe.io.Output {
		return null;
	}

	public static function stderr() : haxe.io.Output {
		return null;
	}

	static function __init__():Void {
		environ = new haxe.ds.StringMap();
		var env = python.lib.Os.environ;

		for (key in env.keys()) {
			environ.set(key, env.get(key, null));
		}
	}
}<commit_msg>implement systemName and use it in getChar<commit_after>import python.lib.Time;


@:coreApi
class Sys {

	static var environ:haxe.ds.StringMap<String>;

	public static function time():Float {
		return Time.time()/1000;
	}

	public static function exit(code:Int):Void {
		python.lib.Sys.exit(code);
	}

	public static function print(v:Dynamic):Void {
		python.Lib.print(v);
	}

	public static function println(v:Dynamic):Void {
		python.Lib.println(v);
	}

	public static function args() : Array<String> {
		var argv = python.lib.Sys.argv;
		return argv.slice(1);
	}

	public static function getEnv( s : String ) : String {
		return environ.get(s);
	}

	public static function putEnv( s : String, v : String ) : Void {
		environ.set(s, v);
	}

	public static function environment() : haxe.ds.StringMap<String> {
		return environ;
	}

	public static function sleep( seconds : Float ) : Void {
		python.lib.Time.sleep(seconds);
	}

	public static function setTimeLocale( loc : String ) : Bool {
		return false;
	}

	public static function getCwd() : String {
		return python.lib.Os.getcwd();
	}

	public static function setCwd( s : String ) : Void {
		python.lib.Os.chdir(s);
	}

	public static function systemName() : String {
		return switch (python.lib.Sys.platform) {
			case x if (StringTools.startsWith(x, "linux")):
				"Linux";
			case "darwin": "Mac";
			case "win32" | "cygwin" : "Windows";
			case _ :
				throw "not supported platform";
		}
	}

	public static function command( cmd : String, ?args : Array<String> ) : Int {
		var args = args == null ? [cmd] : [cmd].concat(args);
		return python.lib.Subprocess.call(args);
	}

	public static function cpuTime() : Float {
		return 0.0;
	}

	public static function executablePath() : String {
		return python.lib.Sys.argv[0];
	}

	public static function getChar( echo : Bool ) : Int {

		var ch = switch (systemName()) {
			case "Linux" | "Mac":
				var fd = python.lib.Sys.stdin.fileno();
				var old = python.lib.Termios.tcgetattr(fd);

				var restore = python.lib.Termios.tcsetattr.bind(fd, python.lib.Termios.TCSADRAIN, old);

				try {
					python.lib.Tty.setraw(fd);
					var x = python.lib.Sys.stdin.read(1);
					restore();
					x.charCodeAt(0);
				} catch (e:Dynamic) {
					restore();
					throw e;
				}

			case "Windows":
				python.lib.Msvcrt.getch().decode("utf-8").charCodeAt(0);
			case x :
				throw "platform " + x + " not supported";
		}
		if (echo) {
			python.Lib.print(String.fromCharCode(ch));
		}
		return ch;
	}

	public static function stdin() : haxe.io.Input {
		return null;
	}

	public static function stdout() : haxe.io.Output {
		return null;
	}

	public static function stderr() : haxe.io.Output {
		return null;
	}

	static function __init__():Void {
		environ = new haxe.ds.StringMap();
		var env = python.lib.Os.environ;

		for (key in env.keys()) {
			environ.set(key, env.get(key, null));
		}
	}
}
{'fraction_non_alphanumeric': 0.14441076840791586, 'fraction_numerical': 0.004991977179532894, 'mean_word_length': 3.2889908256880735, 'pattern_counts': {'":': 4, '<': 11, '<?xml version=': 0, '>': 11, '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': '1513895', 'n_tokens_mistral': 2224, 'n_tokens_neox': 1965, 'n_words': 479}