fix overzealous gitignore and organize flutter a bit

This commit is contained in:
Christien Rioux 2024-02-24 11:43:00 -05:00
parent 019cb5fd79
commit d244c1f6a5
9 changed files with 301 additions and 385 deletions

167
.gitignore vendored
View File

@ -66,172 +66,7 @@ flamegraph.svg
perf.data
perf.data.old
##############################################################################
### Python
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
## Custom for veilid-python
veilid-python/demo/.demokeys
###################################
.vscode/
.idea/

View File

@ -123,59 +123,6 @@ extension DHTRecordDescriptorExt on DHTRecordDescriptor {
}
}
//////////////////////////////////////
/// ValueSubkeyRange
@freezed
class ValueSubkeyRange with _$ValueSubkeyRange {
@Assert('low >= 0 && low <= high', 'range is invalid')
const factory ValueSubkeyRange({
required int low,
required int high,
}) = _ValueSubkeyRange;
factory ValueSubkeyRange.single(int val) =>
ValueSubkeyRange(low: val, high: val);
factory ValueSubkeyRange.fromJson(dynamic json) =>
_$ValueSubkeyRangeFromJson(json as Map<String, dynamic>);
}
extension ValueSubkeyRangeExt on ValueSubkeyRange {
bool contains(int v) => low <= v && v <= high;
List<ValueSubkeyRange> remove(int v) {
if (v < low || v > high) {
return [this];
}
if (v == low) {
if (v == high) {
return [];
} else {
return [ValueSubkeyRange(low: v + 1, high: high)];
}
} else if (v == high) {
return [ValueSubkeyRange(low: low, high: v - 1)];
} else {
return [
ValueSubkeyRange(low: low, high: v - 1),
ValueSubkeyRange(low: v + 1, high: high)
];
}
}
}
extension ListValueSubkeyRangeExt on List<ValueSubkeyRange> {
bool containsSubkey(int v) => indexWhere((e) => e.contains(v)) != -1;
List<ValueSubkeyRange> removeSubkey(int v) {
for (var i = 0; i < length; i++) {
if (this[i].contains(v)) {
return [...sublist(0, i), ...this[i].remove(v), ...sublist(i + 1)];
}
}
return this;
}
}
//////////////////////////////////////
/// ValueData

View File

@ -807,160 +807,6 @@ abstract class _DHTRecordDescriptor implements DHTRecordDescriptor {
throw _privateConstructorUsedError;
}
ValueSubkeyRange _$ValueSubkeyRangeFromJson(Map<String, dynamic> json) {
return _ValueSubkeyRange.fromJson(json);
}
/// @nodoc
mixin _$ValueSubkeyRange {
int get low => throw _privateConstructorUsedError;
int get high => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ValueSubkeyRangeCopyWith<ValueSubkeyRange> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ValueSubkeyRangeCopyWith<$Res> {
factory $ValueSubkeyRangeCopyWith(
ValueSubkeyRange value, $Res Function(ValueSubkeyRange) then) =
_$ValueSubkeyRangeCopyWithImpl<$Res, ValueSubkeyRange>;
@useResult
$Res call({int low, int high});
}
/// @nodoc
class _$ValueSubkeyRangeCopyWithImpl<$Res, $Val extends ValueSubkeyRange>
implements $ValueSubkeyRangeCopyWith<$Res> {
_$ValueSubkeyRangeCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? low = null,
Object? high = null,
}) {
return _then(_value.copyWith(
low: null == low
? _value.low
: low // ignore: cast_nullable_to_non_nullable
as int,
high: null == high
? _value.high
: high // ignore: cast_nullable_to_non_nullable
as int,
) as $Val);
}
}
/// @nodoc
abstract class _$$_ValueSubkeyRangeCopyWith<$Res>
implements $ValueSubkeyRangeCopyWith<$Res> {
factory _$$_ValueSubkeyRangeCopyWith(
_$_ValueSubkeyRange value, $Res Function(_$_ValueSubkeyRange) then) =
__$$_ValueSubkeyRangeCopyWithImpl<$Res>;
@override
@useResult
$Res call({int low, int high});
}
/// @nodoc
class __$$_ValueSubkeyRangeCopyWithImpl<$Res>
extends _$ValueSubkeyRangeCopyWithImpl<$Res, _$_ValueSubkeyRange>
implements _$$_ValueSubkeyRangeCopyWith<$Res> {
__$$_ValueSubkeyRangeCopyWithImpl(
_$_ValueSubkeyRange _value, $Res Function(_$_ValueSubkeyRange) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? low = null,
Object? high = null,
}) {
return _then(_$_ValueSubkeyRange(
low: null == low
? _value.low
: low // ignore: cast_nullable_to_non_nullable
as int,
high: null == high
? _value.high
: high // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
@JsonSerializable()
class _$_ValueSubkeyRange implements _ValueSubkeyRange {
const _$_ValueSubkeyRange({required this.low, required this.high})
: assert(low >= 0 && low <= high, 'range is invalid');
factory _$_ValueSubkeyRange.fromJson(Map<String, dynamic> json) =>
_$$_ValueSubkeyRangeFromJson(json);
@override
final int low;
@override
final int high;
@override
String toString() {
return 'ValueSubkeyRange(low: $low, high: $high)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_ValueSubkeyRange &&
(identical(other.low, low) || other.low == low) &&
(identical(other.high, high) || other.high == high));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, low, high);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$_ValueSubkeyRangeCopyWith<_$_ValueSubkeyRange> get copyWith =>
__$$_ValueSubkeyRangeCopyWithImpl<_$_ValueSubkeyRange>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$_ValueSubkeyRangeToJson(
this,
);
}
}
abstract class _ValueSubkeyRange implements ValueSubkeyRange {
const factory _ValueSubkeyRange(
{required final int low, required final int high}) = _$_ValueSubkeyRange;
factory _ValueSubkeyRange.fromJson(Map<String, dynamic> json) =
_$_ValueSubkeyRange.fromJson;
@override
int get low;
@override
int get high;
@override
@JsonKey(ignore: true)
_$$_ValueSubkeyRangeCopyWith<_$_ValueSubkeyRange> get copyWith =>
throw _privateConstructorUsedError;
}
ValueData _$ValueDataFromJson(Map<String, dynamic> json) {
return _ValueData.fromJson(json);
}

View File

@ -66,18 +66,6 @@ Map<String, dynamic> _$$_DHTRecordDescriptorToJson(
'owner_secret': instance.ownerSecret?.toJson(),
};
_$_ValueSubkeyRange _$$_ValueSubkeyRangeFromJson(Map<String, dynamic> json) =>
_$_ValueSubkeyRange(
low: json['low'] as int,
high: json['high'] as int,
);
Map<String, dynamic> _$$_ValueSubkeyRangeToJson(_$_ValueSubkeyRange instance) =>
<String, dynamic>{
'low': instance.low,
'high': instance.high,
};
_$_ValueData _$$_ValueDataFromJson(Map<String, dynamic> json) => _$_ValueData(
seq: json['seq'] as int,
data: const Uint8ListJsonConverter.jsIsArray().fromJson(json['data']),

View File

@ -0,0 +1,110 @@
import 'dart:math';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'value_subkey_range.freezed.dart';
part 'value_subkey_range.g.dart';
@freezed
class ValueSubkeyRange with _$ValueSubkeyRange {
@Assert('low >= 0 && low <= high', 'range is invalid')
const factory ValueSubkeyRange({
required int low,
required int high,
}) = _ValueSubkeyRange;
factory ValueSubkeyRange.single(int val) =>
ValueSubkeyRange(low: val, high: val);
factory ValueSubkeyRange.fromJson(dynamic json) =>
_$ValueSubkeyRangeFromJson(json as Map<String, dynamic>);
}
extension ValueSubkeyRangeExt on ValueSubkeyRange {
bool contains(int v) => low <= v && v <= high;
List<ValueSubkeyRange> remove(int v) {
if (v < low || v > high) {
return [ValueSubkeyRange(low: low, high: high)];
}
if (v == low) {
if (v == high) {
return [];
} else {
return [ValueSubkeyRange(low: v + 1, high: high)];
}
} else if (v == high) {
return [ValueSubkeyRange(low: low, high: v - 1)];
} else {
return [
ValueSubkeyRange(low: low, high: v - 1),
ValueSubkeyRange(low: v + 1, high: high)
];
}
}
ValueSubkeyRange? intersect(ValueSubkeyRange other) {
if (high < other.low || low > other.high) {
return null;
}
return ValueSubkeyRange(
low: max(low, other.low), high: min(high, other.high));
}
}
extension ListValueSubkeyRangeExt on List<ValueSubkeyRange> {
void validate() {
int? lastHigh;
for (final r in this) {
assert(lastHigh == null || r.low > lastHigh,
'subrange not in order or disjoint');
lastHigh = r.high;
}
}
bool containsSubkey(int v) => indexWhere((e) => e.contains(v)) != -1;
List<ValueSubkeyRange> removeSubkey(int v) {
for (var i = 0; i < length; i++) {
if (this[i].contains(v)) {
return [...sublist(0, i), ...this[i].remove(v), ...sublist(i + 1)];
}
}
return toList();
}
int? get firstSubkey => isNotEmpty ? first.low : null;
List<ValueSubkeyRange> intersectSubkeys(List<ValueSubkeyRange> other) {
final out = <ValueSubkeyRange>[];
for (var i = 0, j = 0; i < length && j < other.length;) {
final vsrThis = this[i];
final vsrOther = other[j];
if (vsrThis.high < vsrOther.low) {
i++;
continue;
}
if (vsrOther.high < vsrThis.low) {
j++;
continue;
}
// Otherwise we intersect
out.add(vsrThis.intersect(vsrOther)!);
// Iterate whichever has a lower high
// If they both have the same high then both ranges are exhausted
// and should be iterated
if (vsrThis.high < vsrOther.high) {
// Iterate this because other could still have some overlaps
i++;
} else if (vsrThis.high == vsrOther.high) {
// Iterate both because both ranges are exhausted
i++;
j++;
} else {
// Iterate other because this could still have some overlaps
j++;
}
}
return out;
}
}

View File

@ -0,0 +1,169 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'value_subkey_range.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
ValueSubkeyRange _$ValueSubkeyRangeFromJson(Map<String, dynamic> json) {
return _ValueSubkeyRange.fromJson(json);
}
/// @nodoc
mixin _$ValueSubkeyRange {
int get low => throw _privateConstructorUsedError;
int get high => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ValueSubkeyRangeCopyWith<ValueSubkeyRange> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ValueSubkeyRangeCopyWith<$Res> {
factory $ValueSubkeyRangeCopyWith(
ValueSubkeyRange value, $Res Function(ValueSubkeyRange) then) =
_$ValueSubkeyRangeCopyWithImpl<$Res, ValueSubkeyRange>;
@useResult
$Res call({int low, int high});
}
/// @nodoc
class _$ValueSubkeyRangeCopyWithImpl<$Res, $Val extends ValueSubkeyRange>
implements $ValueSubkeyRangeCopyWith<$Res> {
_$ValueSubkeyRangeCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? low = null,
Object? high = null,
}) {
return _then(_value.copyWith(
low: null == low
? _value.low
: low // ignore: cast_nullable_to_non_nullable
as int,
high: null == high
? _value.high
: high // ignore: cast_nullable_to_non_nullable
as int,
) as $Val);
}
}
/// @nodoc
abstract class _$$_ValueSubkeyRangeCopyWith<$Res>
implements $ValueSubkeyRangeCopyWith<$Res> {
factory _$$_ValueSubkeyRangeCopyWith(
_$_ValueSubkeyRange value, $Res Function(_$_ValueSubkeyRange) then) =
__$$_ValueSubkeyRangeCopyWithImpl<$Res>;
@override
@useResult
$Res call({int low, int high});
}
/// @nodoc
class __$$_ValueSubkeyRangeCopyWithImpl<$Res>
extends _$ValueSubkeyRangeCopyWithImpl<$Res, _$_ValueSubkeyRange>
implements _$$_ValueSubkeyRangeCopyWith<$Res> {
__$$_ValueSubkeyRangeCopyWithImpl(
_$_ValueSubkeyRange _value, $Res Function(_$_ValueSubkeyRange) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? low = null,
Object? high = null,
}) {
return _then(_$_ValueSubkeyRange(
low: null == low
? _value.low
: low // ignore: cast_nullable_to_non_nullable
as int,
high: null == high
? _value.high
: high // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
@JsonSerializable()
class _$_ValueSubkeyRange implements _ValueSubkeyRange {
const _$_ValueSubkeyRange({required this.low, required this.high})
: assert(low >= 0 && low <= high, 'range is invalid');
factory _$_ValueSubkeyRange.fromJson(Map<String, dynamic> json) =>
_$$_ValueSubkeyRangeFromJson(json);
@override
final int low;
@override
final int high;
@override
String toString() {
return 'ValueSubkeyRange(low: $low, high: $high)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_ValueSubkeyRange &&
(identical(other.low, low) || other.low == low) &&
(identical(other.high, high) || other.high == high));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, low, high);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$_ValueSubkeyRangeCopyWith<_$_ValueSubkeyRange> get copyWith =>
__$$_ValueSubkeyRangeCopyWithImpl<_$_ValueSubkeyRange>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$_ValueSubkeyRangeToJson(
this,
);
}
}
abstract class _ValueSubkeyRange implements ValueSubkeyRange {
const factory _ValueSubkeyRange(
{required final int low, required final int high}) = _$_ValueSubkeyRange;
factory _ValueSubkeyRange.fromJson(Map<String, dynamic> json) =
_$_ValueSubkeyRange.fromJson;
@override
int get low;
@override
int get high;
@override
@JsonKey(ignore: true)
_$$_ValueSubkeyRangeCopyWith<_$_ValueSubkeyRange> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -0,0 +1,19 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'value_subkey_range.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$_ValueSubkeyRange _$$_ValueSubkeyRangeFromJson(Map<String, dynamic> json) =>
_$_ValueSubkeyRange(
low: json['low'] as int,
high: json['high'] as int,
);
Map<String, dynamic> _$$_ValueSubkeyRangeToJson(_$_ValueSubkeyRange instance) =>
<String, dynamic>{
'low': instance.low,
'high': instance.high,
};

View File

@ -18,6 +18,7 @@ import 'veilid_table_db.dart';
export 'default_config.dart';
export 'routing_context.dart';
export 'value_subkey_range.dart';
export 'veilid.dart';
export 'veilid_api_exception.dart';
export 'veilid_config.dart';

View File

@ -158,3 +158,4 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/